[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221205232341.4131240-4-vannapurve@google.com>
Date: Mon, 5 Dec 2022 23:23:38 +0000
From: Vishal Annapurve <vannapurve@...gle.com>
To: x86@...nel.org, kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-kselftest@...r.kernel.org
Cc: pbonzini@...hat.com, vkuznets@...hat.com, wanpengli@...cent.com,
jmattson@...gle.com, joro@...tes.org, tglx@...utronix.de,
mingo@...hat.com, bp@...en8.de, dave.hansen@...ux.intel.com,
hpa@...or.com, shuah@...nel.org, yang.zhong@...el.com,
ricarkol@...gle.com, aaronlewis@...gle.com, wei.w.wang@...el.com,
kirill.shutemov@...ux.intel.com, corbet@....net, hughd@...gle.com,
jlayton@...nel.org, bfields@...ldses.org,
akpm@...ux-foundation.org, chao.p.peng@...ux.intel.com,
yu.c.zhang@...ux.intel.com, jun.nakajima@...el.com,
dave.hansen@...el.com, michael.roth@....com, qperret@...gle.com,
steven.price@....com, ak@...ux.intel.com, david@...hat.com,
luto@...nel.org, vbabka@...e.cz, marcorr@...gle.com,
erdemaktas@...gle.com, pgonda@...gle.com, nikunj@....com,
seanjc@...gle.com, diviness@...gle.com, maz@...nel.org,
dmatlack@...gle.com, axelrasmussen@...gle.com,
maciej.szmigiero@...cle.com, mizhang@...gle.com,
bgardon@...gle.com, ackerleytng@...gle.com,
Vishal Annapurve <vannapurve@...gle.com>
Subject: [V2 PATCH 3/6] KVM: selftests: x86: Add IS_ALIGNED/IS_PAGE_ALIGNED helpers
Add IS_ALIGNED/IS_PAGE_ALIGNED helpers for selftests.
Signed-off-by: Vishal Annapurve <vannapurve@...gle.com>
---
tools/testing/selftests/kvm/include/kvm_util_base.h | 3 +++
tools/testing/selftests/kvm/include/x86_64/processor.h | 1 +
2 files changed, 4 insertions(+)
diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h
index 4ad99f295f2a..7ba32471df50 100644
--- a/tools/testing/selftests/kvm/include/kvm_util_base.h
+++ b/tools/testing/selftests/kvm/include/kvm_util_base.h
@@ -170,6 +170,9 @@ extern enum vm_guest_mode vm_mode_default;
#define MIN_PAGE_SIZE (1U << MIN_PAGE_SHIFT)
#define PTES_PER_MIN_PAGE ptes_per_page(MIN_PAGE_SIZE)
+/* @a is a power of 2 value */
+#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
+
struct vm_guest_mode_params {
unsigned int pa_bits;
unsigned int va_bits;
diff --git a/tools/testing/selftests/kvm/include/x86_64/processor.h b/tools/testing/selftests/kvm/include/x86_64/processor.h
index 5d310abe6c3f..4d5dd9a467e1 100644
--- a/tools/testing/selftests/kvm/include/x86_64/processor.h
+++ b/tools/testing/selftests/kvm/include/x86_64/processor.h
@@ -279,6 +279,7 @@ static inline unsigned int x86_model(unsigned int eax)
#define PAGE_SHIFT 12
#define PAGE_SIZE (1ULL << PAGE_SHIFT)
#define PAGE_MASK (~(PAGE_SIZE-1) & PHYSICAL_PAGE_MASK)
+#define IS_PAGE_ALIGNED(x) IS_ALIGNED(x, PAGE_SIZE)
#define HUGEPAGE_SHIFT(x) (PAGE_SHIFT + (((x) - 1) * 9))
#define HUGEPAGE_SIZE(x) (1UL << HUGEPAGE_SHIFT(x))
--
2.39.0.rc0.267.gcb52ba06e7-goog
Powered by blists - more mailing lists