From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B93DCC3A59F for ; Thu, 29 Aug 2019 10:03:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 91E442339E for ; Thu, 29 Aug 2019 10:03:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727022AbfH2KDW (ORCPT ); Thu, 29 Aug 2019 06:03:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59996 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725853AbfH2KDW (ORCPT ); Thu, 29 Aug 2019 06:03:22 -0400 Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BF67112E5 for ; Thu, 29 Aug 2019 10:03:21 +0000 (UTC) Received: by mail-pg1-f200.google.com with SMTP id q9so1678079pgv.17 for ; Thu, 29 Aug 2019 03:03:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=FLgzdYsri5EILgr23jEU4L5f0KDsqM0mkUgvzUt9vY8=; b=DHdZdB87e4pL3O3QiLWO8W0PSHfLB5ciCxlZV8VH2Z57tCZBMBREItTqKDvmeljVx0 W2NOS69r7x/7ZcnlDpQ6QkC8I9CPNQBdqMk6cQ66SsiMMvR6QZ7guKaVdCCaH+c0AAnx /39W3Xo2+o+Sg5oYOLlbmBR5bh4PljNVKQfoiY8f959zHEJv+EMGd7HOVtyPcfejTgNk Z92/YUjaZGsU5wIE16uv0joKkbdWjrOCHeO3XoW0iiXFTem2fANjxnGGzCVx9MjXJpcW aDlVJWLqv0+Bgddc2uJ1484p9VliZwhBxVyQKO/PIkJYXaPRuCGd/5q0xO73SjyOvn7N BssA== X-Gm-Message-State: APjAAAU0cRJ87X9/gySOSYcRqx7MNdMgO8cGLvkqH68zgI/yw3AEo5XH /BNkf+oDxkROX7YnUlrHVxpJCoXf72eJ1V7nq2Bc/YcOBfx45KZnP52mHCwt1iBR/PsIjdaiYFy dHezTzXWrbCxUM/XfeDcbv/Ol X-Received: by 2002:a17:90a:3b04:: with SMTP id d4mr8947821pjc.80.1567073001249; Thu, 29 Aug 2019 03:03:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqww1/tN21K3EaQdUoDdWqU2F/rzT4no3l16BDXrxXelEGYmmxGilarEYf4qyPPmbELZeai4XA== X-Received: by 2002:a17:90a:3b04:: with SMTP id d4mr8947798pjc.80.1567073000931; Thu, 29 Aug 2019 03:03:20 -0700 (PDT) Received: from xz-x1 ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id b126sm5809085pfa.177.2019.08.29.03.03.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 03:03:19 -0700 (PDT) Date: Thu, 29 Aug 2019 18:03:09 +0800 From: Peter Xu To: Andrew Jones Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Vitaly Kuznetsov , Radim =?utf-8?B?S3LEjW3DocWZ?= , Thomas Huth Subject: Re: [PATCH v2 3/4] KVM: selftests: Introduce VM_MODE_PXXV48_4K Message-ID: <20190829100309.GJ8729@xz-x1> References: <20190829022117.10191-1-peterx@redhat.com> <20190829022117.10191-4-peterx@redhat.com> <20190829094516.fyfhgz7ma2nfazoq@kamzik.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190829094516.fyfhgz7ma2nfazoq@kamzik.brq.redhat.com> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 29, 2019 at 11:45:16AM +0200, Andrew Jones wrote: > On Thu, Aug 29, 2019 at 10:21:16AM +0800, Peter Xu wrote: > > The naming VM_MODE_P52V48_4K is explicit but unclear when used on > > x86_64 machines, because x86_64 machines are having various physical > > address width rather than some static values. Here's some examples: > > > > - Intel Xeon E3-1220: 36 bits > > - Intel Core i7-8650: 39 bits > > - AMD EPYC 7251: 48 bits > > > > All of them are using 48 bits linear address width but with totally > > different physical address width (and most of the old machines should > > be less than 52 bits). > > > > Let's create a new guest mode called VM_MODE_PXXV48_4K for current > > x86_64 tests and make it as the default to replace the old naming of > > VM_MODE_P52V48_4K because it shows more clearly that the PA width is > > not really a constant. Meanwhile we also stop assuming all the x86 > > machines are having 52 bits PA width but instead we fetch the real > > vm->pa_bits from CPUID 0x80000008 during runtime. > > > > We currently make this exclusively used by x86_64 but no other arch. > > > > As a slight touch up, moving DEBUG macro from dirty_log_test.c to > > kvm_util.h so lib can use it too. > > > > Signed-off-by: Peter Xu > > --- > > tools/testing/selftests/kvm/dirty_log_test.c | 5 ++-- > > .../testing/selftests/kvm/include/kvm_util.h | 9 +++++- > > .../selftests/kvm/include/x86_64/processor.h | 3 ++ > > .../selftests/kvm/lib/aarch64/processor.c | 3 ++ > > tools/testing/selftests/kvm/lib/kvm_util.c | 29 ++++++++++++++---- > > .../selftests/kvm/lib/x86_64/processor.c | 30 ++++++++++++++++--- > > 6 files changed, 65 insertions(+), 14 deletions(-) > > > > diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing/selftests/kvm/dirty_log_test.c > > index efb7746a7e99..c86f83cb33e5 100644 > > --- a/tools/testing/selftests/kvm/dirty_log_test.c > > +++ b/tools/testing/selftests/kvm/dirty_log_test.c > > @@ -19,8 +19,6 @@ > > #include "kvm_util.h" > > #include "processor.h" > > > > -#define DEBUG printf > > - > > #define VCPU_ID 1 > > > > /* The memory slot index to track dirty pages */ > > @@ -256,6 +254,7 @@ static void run_test(enum vm_guest_mode mode, unsigned long iterations, > > > > switch (mode) { > > case VM_MODE_P52V48_4K: > > + case VM_MODE_PXXV48_4K: > > guest_pa_bits = 52; > > guest_page_shift = 12; > > break; > > @@ -446,7 +445,7 @@ int main(int argc, char *argv[]) > > #endif > > > > #ifdef __x86_64__ > > - vm_guest_mode_params_init(VM_MODE_P52V48_4K, true, true); > > + vm_guest_mode_params_init(VM_MODE_PXXV48_4K, true, true); > > #endif > > #ifdef __aarch64__ > > vm_guest_mode_params_init(VM_MODE_P40V48_4K, true, true); > > diff --git a/tools/testing/selftests/kvm/include/kvm_util.h b/tools/testing/selftests/kvm/include/kvm_util.h > > index c78faa2ff7f3..430edbacb9b2 100644 > > --- a/tools/testing/selftests/kvm/include/kvm_util.h > > +++ b/tools/testing/selftests/kvm/include/kvm_util.h > > @@ -24,6 +24,10 @@ struct kvm_vm; > > typedef uint64_t vm_paddr_t; /* Virtual Machine (Guest) physical address */ > > typedef uint64_t vm_vaddr_t; /* Virtual Machine (Guest) virtual address */ > > > > +#ifndef DEBUG > > +#define DEBUG printf > > +#endif > > There's no way to turn this off without modifying code. I suggested > > #ifndef NDEBUG > #define dprintf printf > #endif > > which allows the dprintf(...) statements to be removed by compiling with > -DNDEBUG added to CFLAGS. And that would also disable all the asserts(). > That's probably not all that useful, but then again, defining printf() as > DEBUG() isn't useful either if the intention is to always print. Sorry I misread that... Though, I'm afraid even if with above it won't compile with -DNDEBUG because the compiler could start to complain about undefined "dprintf", or even recognize the dprintf as the libc call, dprintf(3). So instead, does below looks ok? #ifdef NDEBUG #define DEBUG(...) #else #define DEBUG(...) printf(__VA_ARGS__); #endif Thanks, -- Peter Xu