Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752613AbdIFJga (ORCPT ); Wed, 6 Sep 2017 05:36:30 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:5560 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752226AbdIFJg0 (ORCPT ); Wed, 6 Sep 2017 05:36:26 -0400 Subject: Re: [PATCH v11 4/6] target-arm: kvm64: detect guest RAS EXTENSION feature To: Peter Maydell References: <1503066227-18251-1-git-send-email-gengdongjiu@huawei.com> <1503066227-18251-5-git-send-email-gengdongjiu@huawei.com> CC: "Michael S. Tsirkin" , Igor Mammedov , Shannon Zhao , Paolo Bonzini , QEMU Developers , qemu-arm , kvm-devel , "edk2-devel@lists.01.org" , Christoffer Dall , Marc Zyngier , "Will Deacon" , James Morse , Tyler Baicar , Ard Biesheuvel , "Ingo Molnar" , , , , arm-mail-list , "kvmarm@lists.cs.columbia.edu" , lkml - Kernel Mailing List , , , , , , , , Huangshaoyu , wuquanming , Linuxarm , From: gengdongjiu Message-ID: <5e3c8d25-6260-d00e-dda3-d160a9973701@huawei.com> Date: Wed, 6 Sep 2017 17:35:33 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.142.68.147] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020205.59AFC179.00A7,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 64c0e4f12e00dd36c338474358858009 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3283 Lines: 93 Hi Peter, Thanks very much for your review, I will check your comments in detail and reply. On 2017/9/6 1:26, Peter Maydell wrote: > On 18 August 2017 at 15:23, Dongjiu Geng wrote: >> check if kvm supports guest RAS EXTENSION. if so, set >> corresponding feature bit for vcpu. >> >> Signed-off-by: Dongjiu Geng >> --- >> linux-headers/linux/kvm.h | 1 + >> target/arm/cpu.h | 3 +++ >> target/arm/kvm64.c | 8 ++++++++ >> 3 files changed, 12 insertions(+) >> >> diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h >> index 7971a4f..2aa176e 100644 >> --- a/linux-headers/linux/kvm.h >> +++ b/linux-headers/linux/kvm.h >> @@ -929,6 +929,7 @@ struct kvm_ppc_resize_hpt { >> #define KVM_CAP_PPC_SMT_POSSIBLE 147 >> #define KVM_CAP_HYPERV_SYNIC2 148 >> #define KVM_CAP_HYPERV_VP_INDEX 149 >> +#define KVM_CAP_ARM_RAS_EXTENSION 150 >> >> #ifdef KVM_CAP_IRQ_ROUTING >> > > Hi. Changes to linux-headers need to be done as a patch of their > own created using scripts/update-linux-headers.sh run against a > mainline kernel tree (and with a commit message that quotes the > kernel commit hash used). This ensures that we have a consistent > set of headers that don't diverge from the kernel copy. > >> diff --git a/target/arm/cpu.h b/target/arm/cpu.h >> index b39d64a..6b0961b 100644 >> --- a/target/arm/cpu.h >> +++ b/target/arm/cpu.h >> @@ -611,6 +611,8 @@ struct ARMCPU { >> >> /* CPU has memory protection unit */ >> bool has_mpu; >> + /* CPU has ras extension unit */ >> + bool has_ras_extension; >> /* PMSAv7 MPU number of supported regions */ >> uint32_t pmsav7_dregion; >> >> @@ -1229,6 +1231,7 @@ enum arm_features { >> ARM_FEATURE_THUMB_DSP, /* DSP insns supported in the Thumb encodings */ >> ARM_FEATURE_PMU, /* has PMU support */ >> ARM_FEATURE_VBAR, /* has cp15 VBAR */ >> + ARM_FEATURE_RAS_EXTENSION, /*has RAS extension support */ > > Missing space after '/*' ? > >> }; >> >> static inline int arm_feature(CPUARMState *env, int feature) >> diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c >> index a16abc8..0781367 100644 >> --- a/target/arm/kvm64.c >> +++ b/target/arm/kvm64.c >> @@ -518,6 +518,14 @@ int kvm_arch_init_vcpu(CPUState *cs) >> unset_feature(&env->features, ARM_FEATURE_PMU); >> } >> >> + if (kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_RAS_EXTENSION)) { >> + cpu->has_ras_extension = true; >> + set_feature(&env->features, ARM_FEATURE_RAS_EXTENSION); >> + } else { >> + cpu->has_ras_extension = false; >> + unset_feature(&env->features, ARM_FEATURE_RAS_EXTENSION); >> + } >> + > > Shouldn't we need to also tell the kernel that we actually want > it to expose RAS to the guest? Compare the PMU code in this > function, where we set a kvm_init_features bit to do this. > (This suggests that your ABI for the kernel part of this feature > may not be correct?) > > You should also not be calling set_feature() here -- if the > CPU features bit doesn't say "this CPU should have the RAS > extensions" we shouldn't create a CPU with them. Instead > you should set it in kvm_arm_get_host_cpu_features() (again, > compare the PMU code). > > thanks > -- PMM > > . >