xen/arm: Add cpu_hwcap bitmap

This will be used to know if a feature, which Xen cares, is available accross
all the CPUs.

This code is a light version of arch/arm64/kernel/cpufeature.c from
Linux v4.6-rc3.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
This commit is contained in:
Julien Grall authored and Stefano Stabellini committed 2016-07-13 18:30:43 +01:00
1 parent 96c53eaa8c
commit bfb489629c
3 files changed
+64

No files matched your search

+1
View File
@@ -6,6 +6,7 @@ subdir-$(CONFIG_ACPI) += acpi
obj-y += bootfdt.o
obj-y += cpu.o
obj-y += cpufeature.o
obj-y += decode.o
obj-y += device.o
obj-y += domain.o
+34
View File
@@ -0,0 +1,34 @@
/*
* Contains CPU feature definitions
*
* Copyright (C) 2015 ARM Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <xen/config.h>
#include <xen/types.h>
#include <xen/init.h>
#include <xen/smp.h>
#include <asm/cpufeature.h>
DECLARE_BITMAP(cpu_hwcaps, ARM_NCAPS);
/*
* Local variables:
* mode: C
* c-file-style: "BSD"
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/
+29
View File
@@ -35,6 +35,35 @@
#endif
#define cpu_has_security (boot_cpu_feature32(security) > 0)
#define ARM_NCAPS 0
#ifndef __ASSEMBLY__
#include <xen/types.h>
#include <xen/lib.h>
#include <xen/bitops.h>
extern DECLARE_BITMAP(cpu_hwcaps, ARM_NCAPS);
static inline bool_t cpus_have_cap(unsigned int num)
{
if ( num >= ARM_NCAPS )
return 0;
return test_bit(num, cpu_hwcaps);
}
static inline void cpus_set_cap(unsigned int num)
{
if (num >= ARM_NCAPS)
printk(XENLOG_WARNING "Attempt to set an illegal CPU capability (%d >= %d)\n",
num, ARM_NCAPS);
else
__set_bit(num, cpu_hwcaps);
}
#endif /* __ASSEMBLY__ */
#endif
/*
* Local variables:
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.