diff mbox

arm64: KVM: Enable support for Cortex-A72

Message ID 1472023297-2756-1-git-send-email-zhaoshenglong@huawei.com (mailing list archive)
State New, archived
Headers show

Commit Message

Shannon Zhao Aug. 24, 2016, 7:21 a.m. UTC
In order to allow KVM to run on Cortex-A72 physical cpus, enable KVM
support for Cortex-A72.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 arch/arm64/include/asm/cputype.h     | 1 +
 arch/arm64/include/uapi/asm/kvm.h    | 3 ++-
 arch/arm64/kvm/guest.c               | 2 ++
 arch/arm64/kvm/sys_regs_generic_v8.c | 2 ++
 4 files changed, 7 insertions(+), 1 deletion(-)

Comments

Suzuki K Poulose Aug. 24, 2016, 8:57 a.m. UTC | #1
On 24/08/16 08:21, Shannon Zhao wrote:
> In order to allow KVM to run on Cortex-A72 physical cpus, enable KVM
> support for Cortex-A72.

Do we really need this change ? Given that A72 is using the generic_v8 table,
it will automatically be supported via the GENERIC_V8 target. That was added
just for this purpose. The pre-existing targets were preserved so that
we don't break the ABI for older user space.

Suzuki
Marc Zyngier Aug. 24, 2016, 9:23 a.m. UTC | #2
On Wed, 24 Aug 2016 15:21:37 +0800
Shannon Zhao <zhaoshenglong@huawei.com> wrote:

Hi Shannon,

> In order to allow KVM to run on Cortex-A72 physical cpus, enable KVM
> support for Cortex-A72.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

Why do we need any of this?

Since bca556ac468a ("arm64/kvm: Add generic v8 KVM target"), we support
any CPU that can run KVM without any change to the kernel, and I've
been running KVM on A72 for quite some time now (Juno r2, Armada 7040).

Am I missing something obvious?

Thanks,

	M.
Shannon Zhao Aug. 24, 2016, 9:23 a.m. UTC | #3
On 2016/8/24 16:57, Suzuki K Poulose wrote:
> On 24/08/16 08:21, Shannon Zhao wrote:
>> In order to allow KVM to run on Cortex-A72 physical cpus, enable KVM
>> support for Cortex-A72.
> 
> Do we really need this change ? Given that A72 is using the generic_v8
> table,
> it will automatically be supported via the GENERIC_V8 target. That was
> added
> just for this purpose. The pre-existing targets were preserved so that
> we don't break the ABI for older user space.
> 
Yes, this works for qemu with "-cpu host". But if it specifies the cpu
type with "-cpu cortex-a72". It will fail without this patch.

The corresponding qemu patches could be found at [1].
[1] https://lists.gnu.org/archive/html/qemu-devel/2016-08/msg03653.html

Thanks,
Suzuki K Poulose Aug. 24, 2016, 10:19 a.m. UTC | #4
On 24/08/16 10:23, Shannon Zhao wrote:
>
>
> On 2016/8/24 16:57, Suzuki K Poulose wrote:
>> On 24/08/16 08:21, Shannon Zhao wrote:
>>> In order to allow KVM to run on Cortex-A72 physical cpus, enable KVM
>>> support for Cortex-A72.
>>
>> Do we really need this change ? Given that A72 is using the generic_v8
>> table,
>> it will automatically be supported via the GENERIC_V8 target. That was
>> added
>> just for this purpose. The pre-existing targets were preserved so that
>> we don't break the ABI for older user space.
>>
> Yes, this works for qemu with "-cpu host". But if it specifies the cpu
> type with "-cpu cortex-a72". It will fail without this patch.

Thats because you specify the expected target from the kernel in Qemu.

I don't know what are the plans for Qemu. Are we going to add every single
ARM CPU released to the target list both in Kernel and Qemu ? e.g, what about
A35, A73 and others from the partners ?

Suzuki

>
> The corresponding qemu patches could be found at [1].
> [1] https://lists.gnu.org/archive/html/qemu-devel/2016-08/msg03653.html
>
> Thanks,
>
Peter Maydell Aug. 24, 2016, 10:54 a.m. UTC | #5
On 24 August 2016 at 11:19, Suzuki K Poulose <Suzuki.Poulose@arm.com> wrote:
> On 24/08/16 10:23, Shannon Zhao wrote:
>> Yes, this works for qemu with "-cpu host". But if it specifies the cpu
>> type with "-cpu cortex-a72". It will fail without this patch.
>
>
> Thats because you specify the expected target from the kernel in Qemu.

That's because if the user said "I really really want a cortex-A72 in
the guest" then we need to tell the kernel "really must be an A72"
(and the kernel can then fake it up in some hypothetical future world
where we can simulate A72 on non-A72 h/w). If the user is happy
with "whatever the kernel's best effort is" that's what -cpu host does.
If there's no way to tell the kernel "must be an A72" we fail the command
because we can't do what the user asked for.

thanks
-- PMM
diff mbox

Patch

diff --git a/arch/arm64/include/asm/cputype.h b/arch/arm64/include/asm/cputype.h
index 9d9fd4b..cf1f638 100644
--- a/arch/arm64/include/asm/cputype.h
+++ b/arch/arm64/include/asm/cputype.h
@@ -76,6 +76,7 @@ 
 #define ARM_CPU_PART_FOUNDATION		0xD00
 #define ARM_CPU_PART_CORTEX_A57		0xD07
 #define ARM_CPU_PART_CORTEX_A53		0xD03
+#define ARM_CPU_PART_CORTEX_A72		0xD08
 
 #define APM_CPU_PART_POTENZA		0x000
 
diff --git a/arch/arm64/include/uapi/asm/kvm.h b/arch/arm64/include/uapi/asm/kvm.h
index f209ea1..af8fbeb 100644
--- a/arch/arm64/include/uapi/asm/kvm.h
+++ b/arch/arm64/include/uapi/asm/kvm.h
@@ -65,8 +65,9 @@  struct kvm_regs {
 #define KVM_ARM_TARGET_CORTEX_A53	4
 /* Generic ARM v8 target */
 #define KVM_ARM_TARGET_GENERIC_V8	5
+#define KVM_ARM_TARGET_CORTEX_A72	6
 
-#define KVM_ARM_NUM_TARGETS		6
+#define KVM_ARM_NUM_TARGETS		7
 
 /* KVM_ARM_SET_DEVICE_ADDR ioctl id encoding */
 #define KVM_ARM_DEVICE_TYPE_SHIFT	0
diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c
index 32fad75..7eed92e 100644
--- a/arch/arm64/kvm/guest.c
+++ b/arch/arm64/kvm/guest.c
@@ -293,6 +293,8 @@  int __attribute_const__ kvm_target_cpu(void)
 			return KVM_ARM_TARGET_CORTEX_A53;
 		case ARM_CPU_PART_CORTEX_A57:
 			return KVM_ARM_TARGET_CORTEX_A57;
+		case ARM_CPU_PART_CORTEX_A72:
+			return KVM_ARM_TARGET_CORTEX_A72;
 		};
 		break;
 	case ARM_CPU_IMP_APM:
diff --git a/arch/arm64/kvm/sys_regs_generic_v8.c b/arch/arm64/kvm/sys_regs_generic_v8.c
index ed90578..cf823e1 100644
--- a/arch/arm64/kvm/sys_regs_generic_v8.c
+++ b/arch/arm64/kvm/sys_regs_generic_v8.c
@@ -92,6 +92,8 @@  static int __init sys_reg_genericv8_init(void)
 					  &genericv8_target_table);
 	kvm_register_target_sys_reg_table(KVM_ARM_TARGET_CORTEX_A57,
 					  &genericv8_target_table);
+	kvm_register_target_sys_reg_table(KVM_ARM_TARGET_CORTEX_A72,
+					  &genericv8_target_table);
 	kvm_register_target_sys_reg_table(KVM_ARM_TARGET_XGENE_POTENZA,
 					  &genericv8_target_table);
 	kvm_register_target_sys_reg_table(KVM_ARM_TARGET_GENERIC_V8,