On Thu, Nov 05, 2020 at 08:18:37AM +0100, Christian Borntraeger wrote: > > > On 04.11.20 22:36, Andrew Jones wrote: > > On Wed, Nov 04, 2020 at 10:23:55PM +0100, Andrew Jones wrote: > >> The code is almost 100% the same anyway. Just move it to common > >> and add a few arch-specific helpers. > >> > >> Signed-off-by: Andrew Jones <drjones@xxxxxxxxxx> > >> --- > >> .../selftests/kvm/include/aarch64/processor.h | 3 ++ > >> .../selftests/kvm/include/s390x/processor.h | 4 +++ > >> .../selftests/kvm/include/x86_64/processor.h | 4 +++ > >> .../selftests/kvm/lib/aarch64/processor.c | 17 ---------- > >> tools/testing/selftests/kvm/lib/kvm_util.c | 26 +++++++++++++++ > >> .../selftests/kvm/lib/s390x/processor.c | 22 ------------- > >> .../selftests/kvm/lib/x86_64/processor.c | 32 ------------------- > >> 7 files changed, 37 insertions(+), 71 deletions(-) > >> > >> diff --git a/tools/testing/selftests/kvm/include/aarch64/processor.h b/tools/testing/selftests/kvm/include/aarch64/processor.h > >> index b7fa0c8551db..5e5849cdd115 100644 > >> --- a/tools/testing/selftests/kvm/include/aarch64/processor.h > >> +++ b/tools/testing/selftests/kvm/include/aarch64/processor.h > >> @@ -9,6 +9,9 @@ > >> > >> #include "kvm_util.h" > >> > >> +#define PTRS_PER_PAGE(page_size) ((page_size) / 8) > >> +#define min_page_size() (4096) > >> +#define min_page_shift() (12) > >> > >> #define ARM64_CORE_REG(x) (KVM_REG_ARM64 | KVM_REG_SIZE_U64 | \ > >> KVM_REG_ARM_CORE | KVM_REG_ARM_CORE_REG(x)) > >> diff --git a/tools/testing/selftests/kvm/include/s390x/processor.h b/tools/testing/selftests/kvm/include/s390x/processor.h > >> index e0e96a5f608c..0952f53c538b 100644 > >> --- a/tools/testing/selftests/kvm/include/s390x/processor.h > >> +++ b/tools/testing/selftests/kvm/include/s390x/processor.h > >> @@ -5,6 +5,10 @@ > >> #ifndef SELFTEST_KVM_PROCESSOR_H > >> #define SELFTEST_KVM_PROCESSOR_H > >> > >> +#define PTRS_PER_PAGE(page_size) ((page_size) / 8) > > > > Doh. I think this 8 is supposed to be a 16 for s390x, considering it > > was dividing by 256 in its version of vm_create_default. I need > > guidance from s390x gurus as to whether or not I should respin though. > > > > Thanks, > > drew > > > > This is kind of tricky. The last level page table is only 2kb (256 entries = 1MB range). > Depending on whether the page table allocation is clever or not (you can have 2 page > tables in one page) this means that indeed 16 might be better. But then you actually > want to change the macro name to PTES_PER_PAGE? Thanks Christian, I'll respin with the macro name change and 16 for s390. drew