From: Paolo Bonzini <pbonzini@redhat.com>
To: Sean Christopherson <seanjc@google.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH] KVM: x86: use inlines instead of macros for is_sev_*guest
Date: Tue, 14 Apr 2026 17:33:49 +0200 [thread overview]
Message-ID: <ef9790f5-38ff-4cae-92c7-fffe527699b4@redhat.com> (raw)
In-Reply-To: <ad1jFw5IPY78nDDw@google.com>
On 4/13/26 23:41, Sean Christopherson wrote:
> On Mon, Apr 13, 2026, Paolo Bonzini wrote:
>> This helps avoiding more embarrassment to this maintainer,
>
> Not building SEV support before pushing to kvm/queue is certainly a choice :-D
Fortunately, the part where I actually do more than a build smoke test
and push to kvm/next has some automation... but the bots are too fast
these days.
> As called out in commit 45d522d3ee9c ("KVM: SVM: Macrofy SEV=n versions of
> sev_xxx_guest()"), use of macros is intentional as gcc-12 at least generates
> suboptimal code if there's a proper function.
>
> That said, gcc-11 (I don't think I have gcc-12 laying around anywhere) generates
> identical code for all of kvm-amd.ko with and without macros, so maybe whatever I
> saw a transient issue? I don't have a strong motivation for caring about any
> version of gcc, so I'm a-ok using __always_inline functions.
Yeah, it seems strange for the compiler to have this problem except at -O0.
> #else
> -static __always_inline bool is_sev_guest(struct kvm_vcpu *vcpu)
> -{
> - return false;
> -}
> -static __always_inline bool is_sev_es_guest(struct kvm_vcpu *vcpu)
> -{
> - return false;
> -}
> -
> -static __always_inline bool is_sev_snp_guest(struct kvm_vcpu *vcpu)
> -{
> - return false;
> -}
> +#define is_sev_guest(vcpu) ({ BUILD_BUG_ON_INVALID((vcpu)->kvm); false; })
> +#define is_sev_es_guest(vcpu) ({ BUILD_BUG_ON_INVALID((vcpu)->kvm); false; })
> +#define is_sev_snp_guest(vcpu) ({ BUILD_BUG_ON_INVALID((vcpu)->kvm); false; })
BUILD_BUG_ON_INVALID isn't great because it doesn't have type checking.
Paolo
prev parent reply other threads:[~2026-04-14 15:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-13 17:00 [PATCH] KVM: x86: use inlines instead of macros for is_sev_*guest Paolo Bonzini
2026-04-13 21:41 ` Sean Christopherson
2026-04-14 15:33 ` Paolo Bonzini [this message]
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=ef9790f5-38ff-4cae-92c7-fffe527699b4@redhat.com \
--to=pbonzini@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=seanjc@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