Re: [PATCH] KVM: x86: Always set kvm_run->if_flag

From: Jim Mattson
Date: Mon Dec 06 2021 - 23:49:18 EST


On Mon, Dec 6, 2021 at 8:31 PM Marc Orr <marcorr@xxxxxxxxxx> wrote:
>
> The kvm_run struct's if_flag is apart of the userspace/kernel API. The

Typo: 'a part'.

> SEV-ES patches failed to set this flag because it's no longer needed by
> QEMU (according to the comment in the source code). However, other
> hypervisors may make use of this flag. Therefore, set the flag for
> guests with encrypted regiesters (i.e., with guest_state_protected set).

Typo: 'registers'.

> Fixes: f1c6366e3043 ("KVM: SVM: Add required changes to support intercepts under SEV-ES")
> Signed-off-by: Marc Orr <marcorr@xxxxxxxxxx>
> ---

> - /*
> - * if_flag is obsolete and useless, so do not bother
> - * setting it for SEV-ES guests. Userspace can just
> - * use kvm_run->ready_for_interrupt_injection.
> - */
> - kvm_run->if_flag = !vcpu->arch.guest_state_protected
> - && (kvm_get_rflags(vcpu) & X86_EFLAGS_IF) != 0;
> -
> + kvm_run->if_flag = static_call(kvm_x86_get_if_flag)(vcpu);

I'm sorry that I missed that change when it first went by. Maintaining
backwards compatibility with existing userspace code is a fundamental
tenet of Linux kernel development.

Acked-by: Jim Mattson <jmattson@xxxxxxxxxx>