From: Paolo Bonzini <pbonzini@redhat.com>
To: Andy Lutomirski <luto@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Stas Sergeev <stsp@list.ru>,
x86@kernel.org
Cc: Cyrill Gorcunov <gorcunov@gmail.com>,
Pavel Emelyanov <xemul@parallels.com>,
kvm list <kvm@vger.kernel.org>
Subject: Re: [RFC/PATCH 1/3] x86/kvm: Rename VMX's segment access rights defines
Date: Sat, 15 Aug 2015 00:47:28 +0200 [thread overview]
Message-ID: <55CE7000.4020505@redhat.com> (raw)
In-Reply-To: <1d5eec06880f454c515af7722d876f1f38f6446c.1439496828.git.luto@kernel.org>
On 13/08/2015 22:18, Andy Lutomirski wrote:
> VMX encodes access rights differently from LAR, and the latter is
> most likely what x86 people think of when they think of "access
> rights".
>
> Rename them to avoid confusion.
Good idea, I've gone ahead and applied it for 4.3.
> Cc: kvm@vger.kernel.org
> Signed-off-by: Andy Lutomirski <luto@kernel.org>
> ---
> arch/x86/include/asm/vmx.h | 46 +++++++++++++++++++++++-----------------------
> arch/x86/kvm/vmx.c | 14 +++++++-------
> 2 files changed, 30 insertions(+), 30 deletions(-)
>
> diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h
> index da772edd19ab..78e243ae1786 100644
> --- a/arch/x86/include/asm/vmx.h
> +++ b/arch/x86/include/asm/vmx.h
> @@ -367,29 +367,29 @@ enum vmcs_field {
> #define TYPE_PHYSICAL_APIC_EVENT (10 << 12)
> #define TYPE_PHYSICAL_APIC_INST (15 << 12)
>
> -/* segment AR */
> -#define SEGMENT_AR_L_MASK (1 << 13)
> -
> -#define AR_TYPE_ACCESSES_MASK 1
> -#define AR_TYPE_READABLE_MASK (1 << 1)
> -#define AR_TYPE_WRITEABLE_MASK (1 << 2)
> -#define AR_TYPE_CODE_MASK (1 << 3)
> -#define AR_TYPE_MASK 0x0f
> -#define AR_TYPE_BUSY_64_TSS 11
> -#define AR_TYPE_BUSY_32_TSS 11
> -#define AR_TYPE_BUSY_16_TSS 3
> -#define AR_TYPE_LDT 2
> -
> -#define AR_UNUSABLE_MASK (1 << 16)
> -#define AR_S_MASK (1 << 4)
> -#define AR_P_MASK (1 << 7)
> -#define AR_L_MASK (1 << 13)
> -#define AR_DB_MASK (1 << 14)
> -#define AR_G_MASK (1 << 15)
> -#define AR_DPL_SHIFT 5
> -#define AR_DPL(ar) (((ar) >> AR_DPL_SHIFT) & 3)
> -
> -#define AR_RESERVD_MASK 0xfffe0f00
> +/* segment AR in VMCS -- these are different from what LAR reports */
> +#define VMX_SEGMENT_AR_L_MASK (1 << 13)
> +
> +#define VMX_AR_TYPE_ACCESSES_MASK 1
> +#define VMX_AR_TYPE_READABLE_MASK (1 << 1)
> +#define VMX_AR_TYPE_WRITEABLE_MASK (1 << 2)
> +#define VMX_AR_TYPE_CODE_MASK (1 << 3)
> +#define VMX_AR_TYPE_MASK 0x0f
> +#define VMX_AR_TYPE_BUSY_64_TSS 11
> +#define VMX_AR_TYPE_BUSY_32_TSS 11
> +#define VMX_AR_TYPE_BUSY_16_TSS 3
> +#define VMX_AR_TYPE_LDT 2
> +
> +#define VMX_AR_UNUSABLE_MASK (1 << 16)
> +#define VMX_AR_S_MASK (1 << 4)
> +#define VMX_AR_P_MASK (1 << 7)
> +#define VMX_AR_L_MASK (1 << 13)
> +#define VMX_AR_DB_MASK (1 << 14)
> +#define VMX_AR_G_MASK (1 << 15)
> +#define VMX_AR_DPL_SHIFT 5
> +#define VMX_AR_DPL(ar) (((ar) >> VMX_AR_DPL_SHIFT) & 3)
> +
> +#define VMX_AR_RESERVD_MASK 0xfffe0f00
>
> #define TSS_PRIVATE_MEMSLOT (KVM_USER_MEM_SLOTS + 0)
> #define APIC_ACCESS_PAGE_PRIVATE_MEMSLOT (KVM_USER_MEM_SLOTS + 1)
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index e856dd566f4c..d7ff79a5135b 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -3423,12 +3423,12 @@ static void enter_lmode(struct kvm_vcpu *vcpu)
> vmx_segment_cache_clear(to_vmx(vcpu));
>
> guest_tr_ar = vmcs_read32(GUEST_TR_AR_BYTES);
> - if ((guest_tr_ar & AR_TYPE_MASK) != AR_TYPE_BUSY_64_TSS) {
> + if ((guest_tr_ar & VMX_AR_TYPE_MASK) != VMX_AR_TYPE_BUSY_64_TSS) {
> pr_debug_ratelimited("%s: tss fixup for long mode. \n",
> __func__);
> vmcs_write32(GUEST_TR_AR_BYTES,
> - (guest_tr_ar & ~AR_TYPE_MASK)
> - | AR_TYPE_BUSY_64_TSS);
> + (guest_tr_ar & ~VMX_AR_TYPE_MASK)
> + | VMX_AR_TYPE_BUSY_64_TSS);
> }
> vmx_set_efer(vcpu, vcpu->arch.efer | EFER_LMA);
> }
> @@ -3719,7 +3719,7 @@ static int vmx_get_cpl(struct kvm_vcpu *vcpu)
> return 0;
> else {
> int ar = vmx_read_guest_seg_ar(vmx, VCPU_SREG_SS);
> - return AR_DPL(ar);
> + return VMX_AR_DPL(ar);
> }
> }
>
> @@ -3847,11 +3847,11 @@ static bool code_segment_valid(struct kvm_vcpu *vcpu)
>
> if (cs.unusable)
> return false;
> - if (~cs.type & (AR_TYPE_CODE_MASK|AR_TYPE_ACCESSES_MASK))
> + if (~cs.type & (VMX_AR_TYPE_CODE_MASK|VMX_AR_TYPE_ACCESSES_MASK))
> return false;
> if (!cs.s)
> return false;
> - if (cs.type & AR_TYPE_WRITEABLE_MASK) {
> + if (cs.type & VMX_AR_TYPE_WRITEABLE_MASK) {
> if (cs.dpl > cs_rpl)
> return false;
> } else {
> @@ -3901,7 +3901,7 @@ static bool data_segment_valid(struct kvm_vcpu *vcpu, int seg)
> return false;
> if (!var.present)
> return false;
> - if (~var.type & (AR_TYPE_CODE_MASK|AR_TYPE_WRITEABLE_MASK)) {
> + if (~var.type & (VMX_AR_TYPE_CODE_MASK|VMX_AR_TYPE_WRITEABLE_MASK)) {
> if (var.dpl < rpl) /* DPL < RPL */
> return false;
> }
>
next prev parent reply other threads:[~2015-08-14 22:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-13 20:18 [RFC/PATCH 0/3] x86/signal/64: A better attempt at SS cleanup Andy Lutomirski
2015-08-13 20:18 ` [RFC/PATCH 1/3] x86/kvm: Rename VMX's segment access rights defines Andy Lutomirski
2015-08-14 22:47 ` Paolo Bonzini [this message]
2015-08-13 20:18 ` [RFC/PATCH 2/3] x86/signal/64: Try to preserve hardware SS across 64-bit signal delivery Andy Lutomirski
2015-08-13 20:25 ` Andy Lutomirski
2015-08-13 21:26 ` Andy Lutomirski
2015-08-13 21:41 ` Linus Torvalds
2015-08-13 21:49 ` Andy Lutomirski
2015-08-13 22:03 ` Andy Lutomirski
2015-08-13 20:18 ` [RFC/PATCH 3/3] x86/signal/64: Add explicit controls for sigcontext SS handling Andy Lutomirski
2015-08-14 20:55 ` Cyrill Gorcunov
2015-08-14 20:57 ` Andy Lutomirski
2015-08-14 21:05 ` Cyrill Gorcunov
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=55CE7000.4020505@redhat.com \
--to=pbonzini@redhat.com \
--cc=gorcunov@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=luto@kernel.org \
--cc=stsp@list.ru \
--cc=torvalds@linux-foundation.org \
--cc=x86@kernel.org \
--cc=xemul@parallels.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.