kvmarm.lists.cs.columbia.edu archive mirror
 help / color / mirror / Atom feed
From: Shannon Zhao <zhaoshenglong@huawei.com>
To: Marc Zyngier <marc.zyngier@arm.com>,
	kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org
Subject: Re: [PATCH 1/3] KVM: ARM64: Fix wrong use of the CPSR MODE mask
Date: Thu, 14 Jan 2016 09:27:34 +0800	[thread overview]
Message-ID: <5696F986.8010401@huawei.com> (raw)
In-Reply-To: <56961989.9080404@arm.com>



On 2016/1/13 17:31, Marc Zyngier wrote:
> On 13/01/16 09:16, Shannon Zhao wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> The values of CPSR MODE mask are different between aarch32 and aarch64.
>> It should use the right one according to the execution state.
>>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>>  arch/arm64/include/asm/kvm_emulate.h | 8 ++++++--
>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h
>> index 3066328..779a587 100644
>> --- a/arch/arm64/include/asm/kvm_emulate.h
>> +++ b/arch/arm64/include/asm/kvm_emulate.h
>> @@ -127,10 +127,14 @@ static inline unsigned long *vcpu_spsr(const struct kvm_vcpu *vcpu)
>>  
>>  static inline bool vcpu_mode_priv(const struct kvm_vcpu *vcpu)
>>  {
>> -	u32 mode = *vcpu_cpsr(vcpu) & PSR_MODE_MASK;
>> +	u32 mode;
>>  
>> -	if (vcpu_mode_is_32bit(vcpu))
>> +	if (vcpu_mode_is_32bit(vcpu)) {
>> +		mode = *vcpu_cpsr(vcpu) & COMPAT_PSR_MODE_MASK;
>>  		return mode > COMPAT_PSR_MODE_USR;
>> +	}
>> +
>> +	mode = *vcpu_cpsr(vcpu) & PSR_MODE_MASK;
>>  
>>  	return mode != PSR_MODE_EL0t;
>>  }
>>
> 
> Nice catch. At the moment, it will only affect perf's is_user_mode()
> with a 32bit guest (always reporting the guest as running in kernel
> mode), so that's not a big deal with mainline (but it clearly has a much
> bigger implication with the PMU support).
> 
> Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
> 
Thanks, maybe this should backport to stable kernel. Sorry I forgot to
CC stable.

-- 
Shannon

  reply	other threads:[~2016-01-14  1:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-13  9:16 [PATCH 0/3] Three fixes for KVM ARM64 Shannon Zhao
2016-01-13  9:16 ` [PATCH 1/3] KVM: ARM64: Fix wrong use of the CPSR MODE mask Shannon Zhao
2016-01-13  9:31   ` Marc Zyngier
2016-01-14  1:27     ` Shannon Zhao [this message]
2016-01-13  9:16 ` [PATCH 2/3] KVM: ARM64: Fix comments of the CP handler Shannon Zhao
2016-01-13  9:32   ` Marc Zyngier
2016-01-13  9:16 ` [PATCH 3/3] KVM: ARM64: Fix guest dead loop when register accessor returns false Shannon Zhao
2016-01-13 11:02   ` Marc Zyngier
2016-01-13 14:20     ` Shannon Zhao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5696F986.8010401@huawei.com \
    --to=zhaoshenglong@huawei.com \
    --cc=christoffer.dall@linaro.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=marc.zyngier@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).