[PATCH v2 0/2] KVM: TDX: INIT_MEM_REGION fixes

Sean Christopherson posted 2 patches 1 month, 3 weeks ago
arch/x86/kvm/vmx/tdx.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
[PATCH v2 0/2] KVM: TDX: INIT_MEM_REGION fixes
Posted by Sean Christopherson 1 month, 3 weeks ago
I completely lost track of this, meant to post these patches weeks ago.
Compile tested only.

v2:
 - Fix an off-by-one bug.
 - Use gpa_t instead of raw u64.
 - Tweak the order of checks to bundle similar checks together, and to perform
   the super basic checks (alignment, size, etc.) first.

v1: https://lore.kernel.org/all/ak0skG064rhKUC8d@google.com

Haotian Jiang (1):
  KVM: TDX: Reject INIT_MEM_REGION if number of bytes would overflow a
    u64

Sean Christopherson (1):
  KVM: TDX: Fix a benign off-by-one bug on the end GPA for
    INIT_MEM_REGION

 arch/x86/kvm/vmx/tdx.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)


base-commit: a806d364ef288a6443a1337820ea8410a7ccc6b3
-- 
2.55.0.679.g6767b8d81c-goog
Re: [PATCH v2 0/2] KVM: TDX: INIT_MEM_REGION fixes
Posted by Ackerley Tng 1 week, 2 days ago
Sean Christopherson <seanjc@google.com> writes:

> I completely lost track of this, meant to post these patches weeks ago.
> Compile tested only.
>
> v2:
>  - Fix an off-by-one bug.
>  - Use gpa_t instead of raw u64.
>  - Tweak the order of checks to bundle similar checks together, and to perform
>    the super basic checks (alignment, size, etc.) first.
>
> v1: https://lore.kernel.org/all/ak0skG064rhKUC8d@google.com
>
> Haotian Jiang (1):
>   KVM: TDX: Reject INIT_MEM_REGION if number of bytes would overflow a
>     u64
>
> Sean Christopherson (1):
>   KVM: TDX: Fix a benign off-by-one bug on the end GPA for
>     INIT_MEM_REGION
>
>  arch/x86/kvm/vmx/tdx.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>
>
> base-commit: a806d364ef288a6443a1337820ea8410a7ccc6b3
> --
> 2.55.0.679.g6767b8d81c-goog

Looks good to me, just a question on the use of check_*_overflow: I
thought Sean didn't like burying an out-param in an if-statement? [1]

[1] https://lore.kernel.org/all/ag8BmtzxTlcuA_zy@google.com/

Reviewed-by: Ackerley Tng <ackerleytng@google.com>
Re: [PATCH v2 0/2] KVM: TDX: INIT_MEM_REGION fixes
Posted by Sean Christopherson 1 week, 2 days ago
On Tue, Sep 22, 2026, Ackerley Tng wrote:
> Sean Christopherson <seanjc@google.com> writes:
> 
> > I completely lost track of this, meant to post these patches weeks ago.
> > Compile tested only.
> >
> > v2:
> >  - Fix an off-by-one bug.
> >  - Use gpa_t instead of raw u64.
> >  - Tweak the order of checks to bundle similar checks together, and to perform
> >    the super basic checks (alignment, size, etc.) first.
> >
> > v1: https://lore.kernel.org/all/ak0skG064rhKUC8d@google.com
> >
> > Haotian Jiang (1):
> >   KVM: TDX: Reject INIT_MEM_REGION if number of bytes would overflow a
> >     u64
> >
> > Sean Christopherson (1):
> >   KVM: TDX: Fix a benign off-by-one bug on the end GPA for
> >     INIT_MEM_REGION
> >
> >  arch/x86/kvm/vmx/tdx.c | 10 +++++++---
> >  1 file changed, 7 insertions(+), 3 deletions(-)
> >
> >
> > base-commit: a806d364ef288a6443a1337820ea8410a7ccc6b3
> > --
> > 2.55.0.679.g6767b8d81c-goog
> 
> Looks good to me, just a question on the use of check_*_overflow: I
> thought Sean didn't like burying an out-param in an if-statement? [1]

I don't, but in this case I found it to be the lesser evil.  I think it helps
that both the out-params are used only in the same if-statement.  One could argue
that's even *more* evil, but t doesn't "surprise" me as much, e.g. I'm not having
to hunt for where some variable in the main loop is set.

> [1] https://lore.kernel.org/all/ag8BmtzxTlcuA_zy@google.com
Re: [PATCH v2 0/2] KVM: TDX: INIT_MEM_REGION fixes
Posted by Sean Christopherson 1 week, 3 days ago
On Thu, 06 Aug 2026 10:06:00 -0700, Sean Christopherson wrote:
> I completely lost track of this, meant to post these patches weeks ago.
> Compile tested only.
> 
> v2:
>  - Fix an off-by-one bug.
>  - Use gpa_t instead of raw u64.
>  - Tweak the order of checks to bundle similar checks together, and to perform
>    the super basic checks (alignment, size, etc.) first.
> 
> [...]

Applied to kvm-x86 vmx, thanks!

[1/2] KVM: TDX: Reject INIT_MEM_REGION if number of bytes would overflow a u64
      https://github.com/kvm-x86/linux/commit/7c9a2e3a4564
[2/2] KVM: TDX: Fix a benign off-by-one bug on the end GPA for INIT_MEM_REGION
      https://github.com/kvm-x86/linux/commit/872aae89167c

--
https://github.com/kvm-x86/linux/tree/next