From: Jan Kiszka <jan.kiszka@siemens.com>
To: Peter Feiner <pfeiner@google.com>, Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [kvm-unit-tests 2/5] x86: vmx: Named constant: EPT_ADDR_MASK
Date: Tue, 1 Mar 2016 22:27:34 +0100 [thread overview]
Message-ID: <56D60946.9000504@siemens.com> (raw)
In-Reply-To: <CAM3pwhELSa3CKFXQbSBhWqQDRY4WtcAe1ESDbwtZt0WSC6QQ8Q@mail.gmail.com>
On 2016-03-01 22:16, Peter Feiner wrote:
> On Tue, Mar 1, 2016 at 1:12 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
>>
>>
>> On 01/03/2016 20:30, Peter Feiner wrote:
>>> Signed-off-by: Peter Feiner <pfeiner@google.com>
>>> ---
>>> x86/vmx.c | 6 +++---
>>> x86/vmx.h | 1 +
>>> 2 files changed, 4 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/x86/vmx.c b/x86/vmx.c
>>> index 3fa1a73..9811a28 100644
>>> --- a/x86/vmx.c
>>> +++ b/x86/vmx.c
>>> @@ -246,7 +246,7 @@ void install_ept_entry(unsigned long *pml4,
>>> | EPT_RA | EPT_WA | EPT_EA;
>>> } else
>>> pt[offset] &= ~EPT_LARGE_PAGE;
>>> - pt = phys_to_virt(pt[offset] & 0xffffffffff000ull);
>>> + pt = phys_to_virt(pt[offset] & EPT_ADDR_MASK);
>>> }
>>> offset = ((unsigned long)guest_addr >> ((level-1) *
>>> EPT_PGDIR_WIDTH + 12)) & EPT_PGDIR_MASK;
>>> @@ -334,7 +334,7 @@ unsigned long get_ept_pte(unsigned long *pml4,
>>> break;
>>> if (l < 4 && (pte & EPT_LARGE_PAGE))
>>> return pte;
>>> - pt = (unsigned long *)(pte & 0xffffffffff000ull);
>>> + pt = (unsigned long *)(pte & EPT_ADDR_MASK);
>>> }
>>> offset = (guest_addr >> (((l-1) * EPT_PGDIR_WIDTH) + 12))
>>> & EPT_PGDIR_MASK;
>>> @@ -378,7 +378,7 @@ int set_ept_pte(unsigned long *pml4, unsigned long guest_addr,
>>> break;
>>> if (!(pt[offset] & (EPT_PRESENT)))
>>> return -1;
>>> - pt = (unsigned long *)(pt[offset] & 0xffffffffff000ull);
>>> + pt = (unsigned long *)(pt[offset] & EPT_ADDR_MASK);
>>> }
>>> offset = (guest_addr >> (((l-1) * EPT_PGDIR_WIDTH) + 12))
>>> & EPT_PGDIR_MASK;
>>> diff --git a/x86/vmx.h b/x86/vmx.h
>>> index cae9274..c2a2121 100644
>>> --- a/x86/vmx.h
>>> +++ b/x86/vmx.h
>>> @@ -466,6 +466,7 @@ enum Ctrl1 {
>>> #define EPT_PAGE_LEVEL 4
>>> #define EPT_PGDIR_WIDTH 9
>>> #define EPT_PGDIR_MASK 511
>>> +#define EPT_ADDR_MASK 0xffffffffff000ul
>>
>> This is just PAGE_MASK, defined one line below. :)
>>
>> Paolo
>>
>>> #define PAGE_MASK (~(PAGE_SIZE-1))
>>> #define PAGE_MASK_2M (~(PAGE_SIZE_2M-1))
>>>
>>>
>
> It's not precisely the same thing since PAGE_MASK sets the upper
> reserved bits :-)
>
> I'll send v2.
Consider defining the constant as GENMASK(51, 12) (from linux/bitops.h).
A while back, I re-invented this macro for Jailhouse, and I just
realized that the kernel has the very same thing. It makes such bitmasks
much more readable (and verifiable when looking at specs).
Jan
--
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux
next prev parent reply other threads:[~2016-03-01 21:27 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-01 19:30 [kvm-unit-tests 0/5] Split large EPT mappings properly Peter Feiner
2016-03-01 19:30 ` [kvm-unit-tests 1/5] x86: vmx.h: trivial whitespace fixes Peter Feiner
2016-03-01 19:30 ` [kvm-unit-tests 2/5] x86: vmx: Named constant: EPT_ADDR_MASK Peter Feiner
2016-03-01 21:12 ` Paolo Bonzini
2016-03-01 21:16 ` Peter Feiner
2016-03-01 21:27 ` Jan Kiszka [this message]
2016-03-01 21:36 ` Paolo Bonzini
2016-03-01 19:30 ` [kvm-unit-tests 3/5] x86: vmx: Named constant: EPT_LEVEL_SHIFT Peter Feiner
2016-03-01 19:30 ` [kvm-unit-tests 4/5] x86: vmx: split large EPTEs in install_ept_entry Peter Feiner
2016-03-01 19:30 ` [kvm-unit-tests 5/5] x86: vmx: don't explicitly split identity EPT map Peter Feiner
2016-03-01 21:13 ` [kvm-unit-tests 0/5] Split large EPT mappings properly Paolo Bonzini
2016-03-01 22:34 ` [kvm-unit-tests v2 0/6] " Peter Feiner
2016-03-01 22:34 ` [kvm-unit-tests v2 1/6] x86: vmx.h: trivial whitespace fixes Peter Feiner
2016-03-01 22:34 ` [kvm-unit-tests v2 2/6] lib: generic bitops.h Peter Feiner
2016-03-01 22:34 ` [kvm-unit-tests v2 3/6] x86: vmx: Named constant: EPT_ADDR_MASK Peter Feiner
2016-03-02 6:24 ` Jan Kiszka
2016-03-02 8:47 ` Paolo Bonzini
2016-03-02 16:50 ` Peter Feiner
2016-03-01 22:34 ` [kvm-unit-tests v2 4/6] x86: vmx: Named constant: EPT_LEVEL_SHIFT Peter Feiner
2016-03-01 22:34 ` [kvm-unit-tests v2 5/6] x86: vmx: split large EPTEs in install_ept_entry Peter Feiner
2016-03-01 22:34 ` [kvm-unit-tests v2 6/6] x86: vmx: don't explicitly split identity EPT map Peter Feiner
2016-03-02 17:10 ` [kvm-unit-tests v3 0/6] Split large EPT mappings properly Peter Feiner
2016-03-02 17:10 ` [kvm-unit-tests v3 1/6] x86: vmx.h: trivial whitespace fixes Peter Feiner
2016-03-02 17:10 ` [kvm-unit-tests v3 2/6] lib: generic bitops.h Peter Feiner
2016-03-02 18:13 ` Andrew Jones
2016-03-02 17:10 ` [kvm-unit-tests v3 3/6] x86: vmx: Named constant: EPT_ADDR_MASK Peter Feiner
2016-03-02 17:10 ` [kvm-unit-tests v3 4/6] x86: vmx: Named constant: EPT_LEVEL_SHIFT Peter Feiner
2016-03-02 17:10 ` [kvm-unit-tests v3 5/6] x86: vmx: split large EPTEs in install_ept_entry Peter Feiner
2016-03-02 17:10 ` [kvm-unit-tests v3 6/6] x86: vmx: don't explicitly split identity EPT map Peter Feiner
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=56D60946.9000504@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=pfeiner@google.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