From nobody Thu Dec 18 19:05:17 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F52219CCF7 for ; Thu, 25 Jul 2024 15:01:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721919689; cv=none; b=L6yP0X7uS8RSVjDJCfzACCnOKl1WYBUMsI8nbed79MeXPLCknugKOjNukF5ramS+LbCUx2OyBi60Jczf+3ctNiLpmunkK+AserQHC3cwNPrQlQwfnbAxLKZSlfUw5GtKQsuWjtoJz0GS4iYprzu+Mr4qwhdOsitdv9JCcUExfp0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721919689; c=relaxed/simple; bh=KhGQutkuUF3lfyGgp4QnoP1AzxbSh/MzUrDflGzKQWg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VarNQvFbMgedu73ToOdSVJbKmo3QYB1Tv/TiUqa7S9Kgi9/XnzgGwUT4+P/3J1KGPLqop0zy1B0BZHIz/GfWmUpmiFr44imF+v4B39Vv7do4kD+ODPp8SJIlodpfxXr86rvP3884Uy3lV47o9AXzEUTSyM04GNjz15xoQzrLYr8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=HI9hlt+k; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HI9hlt+k" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721919687; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DVAMN3U4tDyBzO81PDmsnSjhouOzOOdSN5L9d+/nJFg=; b=HI9hlt+kgiCZVABSKITpVDvjUqv2AVFbSqUVBFO5ysPBLMZz5hYYpxWfJIm5O3xyooIOwt bHyBaVx8bgXvL2ZxXQogIqgcMBKeGOWtEYETtIV6e5o9J1aBgvWJczSc3Lh/khisUpBhYm poFSBqY8d6/+Fmc6+ZPVViRD1GP9Gp4= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-156-A0MbT0NwNbuP-TLZwjqGGA-1; Thu, 25 Jul 2024 11:01:24 -0400 X-MC-Unique: A0MbT0NwNbuP-TLZwjqGGA-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D5B5D1956046; Thu, 25 Jul 2024 15:01:18 +0000 (UTC) Received: from starship.lan (unknown [10.22.8.132]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5DD211955F40; Thu, 25 Jul 2024 15:01:16 +0000 (UTC) From: Maxim Levitsky To: kvm@vger.kernel.org Cc: Dave Hansen , Sean Christopherson , Borislav Petkov , Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org, Ingo Molnar , Paolo Bonzini , "H. Peter Anvin" , Maxim Levitsky Subject: [PATCH 2/2] KVM: SVM: fix emulation of msr reads/writes of MSR_FS_BASE and MSR_GS_BASE Date: Thu, 25 Jul 2024 11:01:10 -0400 Message-Id: <20240725150110.327601-3-mlevitsk@redhat.com> In-Reply-To: <20240725150110.327601-1-mlevitsk@redhat.com> References: <20240725150110.327601-1-mlevitsk@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" If these msrs are read by the emulator (e.g due to 'force emulation' prefix= ), SVM code currently fails to extract the corresponding segment bases, and return them to the emulator. Fix that. Signed-off-by: Maxim Levitsky --- arch/x86/kvm/svm/svm.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index c58da281f14f..3fc01ba2bd4a 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -2875,6 +2875,12 @@ static int svm_get_msr(struct kvm_vcpu *vcpu, struct= msr_data *msr_info) case MSR_CSTAR: msr_info->data =3D svm->vmcb01.ptr->save.cstar; break; + case MSR_GS_BASE: + msr_info->data =3D svm->vmcb01.ptr->save.gs.base; + break; + case MSR_FS_BASE: + msr_info->data =3D svm->vmcb01.ptr->save.fs.base; + break; case MSR_KERNEL_GS_BASE: msr_info->data =3D svm->vmcb01.ptr->save.kernel_gs_base; break; @@ -3100,6 +3106,12 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct= msr_data *msr) case MSR_CSTAR: svm->vmcb01.ptr->save.cstar =3D data; break; + case MSR_GS_BASE: + svm->vmcb01.ptr->save.gs.base =3D data; + break; + case MSR_FS_BASE: + svm->vmcb01.ptr->save.fs.base =3D data; + break; case MSR_KERNEL_GS_BASE: svm->vmcb01.ptr->save.kernel_gs_base =3D data; break; --=20 2.26.3