From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [kvm-unit-tests PATCH v8 08/12] x86: Cleanup PAGE_* constants Date: Mon, 6 Jun 2016 17:21:23 +0200 Message-ID: References: <67978bcc43b1e15d826583ce26b828ea4bdc6b7e.1465207665.git.agordeev@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Andrew Jones , Thomas Huth , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= To: Alexander Gordeev , kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:58076 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752457AbcFFPVa (ORCPT ); Mon, 6 Jun 2016 11:21:30 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5D8F6C04B311 for ; Mon, 6 Jun 2016 15:21:30 +0000 (UTC) In-Reply-To: <67978bcc43b1e15d826583ce26b828ea4bdc6b7e.1465207665.git.agordeev@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 06/06/2016 12:25, Alexander Gordeev wrote: > Cc: Andrew Jones > Cc: Thomas Huth > Cc: Paolo Bonzini > Cc: Radim Kr=C4=8Dm=C3=A1=C5=99 > Reviewed-by: Andrew Jones > Signed-off-by: Alexander Gordeev > --- > lib/x86/asm/page.h | 10 +++++++++- > x86/access.c | 4 +--- > x86/vmx.h | 2 +- > 3 files changed, 11 insertions(+), 5 deletions(-) >=20 > diff --git a/lib/x86/asm/page.h b/lib/x86/asm/page.h > index d4580b40f5e8..916462d758ac 100644 > --- a/lib/x86/asm/page.h > +++ b/lib/x86/asm/page.h > @@ -7,7 +7,14 @@ > */ > =20 > =20 > -#define PAGE_SIZE 4096ul > +#include No linux/ includes here, but you can just use the existing #define PAGE_SIZE 4096ul definition. Paolo > + > +#define PAGE_SHIFT 12 > +#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) > +#define PAGE_MASK (~(PAGE_SIZE-1)) > + > +#ifndef __ASSEMBLY__ > + > #ifdef __x86_64__ > #define LARGE_PAGE_SIZE (512 * PAGE_SIZE) > #else > @@ -30,4 +37,5 @@ > #define PGDIR_MASK 1023 > #endif > =20 > +#endif /* !__ASSEMBLY__ */ > #endif > diff --git a/x86/access.c b/x86/access.c > index 4acaee5c6b4d..aaf805d1ea7c 100644 > --- a/x86/access.c > +++ b/x86/access.c > @@ -2,6 +2,7 @@ > #include "libcflat.h" > #include "desc.h" > #include "processor.h" > +#include "asm/page.h" > =20 > #define smp_id() 0 > =20 > @@ -15,9 +16,6 @@ static int cpuid_7_ebx; > static int cpuid_7_ecx; > static int invalid_mask; > =20 > -#define PAGE_SIZE ((pt_element_t)4096) > -#define PAGE_MASK (~(PAGE_SIZE-1)) > - > #define PT_BASE_ADDR_MASK ((pt_element_t)((((pt_element_t)1 << 40) -= 1) & PAGE_MASK)) > #define PT_PSE_BASE_ADDR_MASK (PT_BASE_ADDR_MASK & ~(1ull << 21)) > =20 > diff --git a/x86/vmx.h b/x86/vmx.h > index d6bc217cb1cf..27f345190bee 100644 > --- a/x86/vmx.h > +++ b/x86/vmx.h > @@ -4,6 +4,7 @@ > #include "libcflat.h" > #include "processor.h" > #include "bitops.h" > +#include "asm/page.h" > =20 > struct vmcs { > u32 revision_id; /* vmcs revision identifier */ > @@ -476,7 +477,6 @@ enum Ctrl1 { > #define EPT_PGDIR_ENTRIES (1 << EPT_PGDIR_WIDTH) > #define EPT_LEVEL_SHIFT(level) (((level)-1) * EPT_PGDIR_WIDTH + 12) > #define EPT_ADDR_MASK GENMASK_ULL(51, 12) > -#define PAGE_MASK (~(PAGE_SIZE-1)) > #define PAGE_MASK_2M (~(PAGE_SIZE_2M-1)) > =20 > #define EPT_VLT_RD 1 >=20