From patchwork Fri Feb 23 20:42:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13569964 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCF75149387 for ; Fri, 23 Feb 2024 20:42:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708720959; cv=none; b=AG3R6CuIheCFImzdGD6pfYJHRppxGvbFQKybI1ijmpac2XmiwinHxr48BIxWPx0ldrJtG6joR//ggpaPOWz3Wq5rvu2SHJB7ojAqRvt2n4G+ccgivVJ5ZrBwPKZ8tqAT1G+s1WfU4gVqM0LglbAPl/GsVuT9elOgBN3TVTV5rDY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708720959; c=relaxed/simple; bh=6ShF5KyZmeoKeVwczIN545JawDqkwUK3No4F9ATa188=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Wv1AnotGc8BLpaA5GTjKZfulwHJp7F0rM+uBUz0bSAyGqgiPs3vDPGig8SPP0GlhhQUKWoe3qaxJjir6HoWjZNLgc2FN1ZfR2lCWjW9IhhflRo7XtDwZc3ZajuhefAlH+NVWEt8bE+Ww1BpTpqtXdJzzi8qoptb3Zj/GgjYDu/Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=RyOWud10; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="RyOWud10" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-299cae4f36bso1015531a91.1 for ; Fri, 23 Feb 2024 12:42:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708720957; x=1709325757; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=d647qV5YXXlk1eKRQGMECxhpXnyYK5AYh5qfDVrkHVc=; b=RyOWud10QA5VdBHeA7MTnjX//5DW7G102NkiFYhDmENz3W0Nm1mxEejoVYD4zJRDvk zJdueDtusFZLRLRn7m57h4uaZY6DJnMBzkMkxVle/eNCRx20LDz8+KrT09H4tD3s+D1e j7K9K+XLpdT+U1VGsft22epAZBn9WbPvCb306shZ5/6a/1Rol/Zlq3SbMIbF94Cc4UqT 0gUA32XXwguBZVdrpzadAcF8i2+pPZia3xYGQBuDx3NAwfMu4UYKHmmqeREhaufOWLtt 11T6UXO7IGySIs6HI7bBxNK6Cy32RHKA1NFza2m8nHXGX3GXtpNujnFbP5IYbx/Z6HvQ EYBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708720957; x=1709325757; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=d647qV5YXXlk1eKRQGMECxhpXnyYK5AYh5qfDVrkHVc=; b=w0xHg+hejccrAdgX3wxk/IpNp3ufgLMCbpyeSRfBLUSSlOBY1doe2G4ubT3LZ8i/mm MJrp7ixCCRRbMIfEbk6WTsR8nsc5f8NTbod45r8nPp3riPr3wZgUwXFHFKTPsUtJbL1r I+y7FefiKC2DwSkYRie+qAVPb77PT8CFMgfh3/wYDnXDxQOhzzM5WLI7/SbiWhAlYN+j 5fb1uosVOr9v4jezDlbR/nr/IBHF8bQ9CUpH0TiWhFjUmRPGPjnwUEv+feN6O8wyT2Iv pWnkg9Hq8QRclH3rU9CqHnTuXgjSjkH0lhCQdLe8w6KvgXWFISHydRLl907TuRmNlEca J+KA== X-Gm-Message-State: AOJu0YyeoSUVrZZHvf/O576ZLw/VISRAdj40hx5IE7AVPlJkJ+mMe35u 7fR1jI58V9ZLcY8338DbIjIAMhx/eKaCd7LdPkojp1F7FO+5ldBXo8S40OUltq9RS0xVJj+JH7j 07w== X-Google-Smtp-Source: AGHT+IG85Eo/bKisu1UinMdZey7PLDTuVrcfcBNR6TXcGUwOM3M/DeCNU42rxbMIRizLqv1Fd0FMSNF/7gw= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:90b:2e8f:b0:296:de77:56c9 with SMTP id sn15-20020a17090b2e8f00b00296de7756c9mr2215pjb.2.1708720957080; Fri, 23 Feb 2024 12:42:37 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 23 Feb 2024 12:42:26 -0800 In-Reply-To: <20240223204233.3337324-1-seanjc@google.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240223204233.3337324-1-seanjc@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240223204233.3337324-2-seanjc@google.com> Subject: [PATCH 1/8] KVM: SVM: Create a stack frame in __svm_vcpu_run() for unwinding From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Tom Lendacky , Michael Roth , Alexey Kardashevskiy Unconditionally create a stack frame in __svm_vcpu_run() to play nice with unwinding via frame pointers, at least until the point where RBP is loaded with the guest's value. Don't bother conditioning the code on CONFIG_FRAME_POINTER=y, as RBP needs to be saved and restored anyways (due to it being clobbered with the guest's value); omitting the "MOV RSP, RBP" is not worth the extra #ifdef. Creating a stack frame will allow removing the OBJECT_FILES_NON_STANDARD tag from vmenter.S once __svm_sev_es_vcpu_run() is fixed to not stomp all over RBP for no reason. Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/vmenter.S | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kvm/svm/vmenter.S b/arch/x86/kvm/svm/vmenter.S index 9499f9c6b077..ee5d5a30da88 100644 --- a/arch/x86/kvm/svm/vmenter.S +++ b/arch/x86/kvm/svm/vmenter.S @@ -99,6 +99,7 @@ */ SYM_FUNC_START(__svm_vcpu_run) push %_ASM_BP + mov %_ASM_SP, %_ASM_BP #ifdef CONFIG_X86_64 push %r15 push %r14 From patchwork Fri Feb 23 20:42:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13569965 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CABE314F9F3 for ; Fri, 23 Feb 2024 20:42:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708720961; cv=none; b=pgOKpceQHISxH/ZDN89TFqHRjZ3OB6b7S52CAmmyGusOL+bM3uDms0cMTJd2f2ek9trsJX/a8mRe/lNrj7Ai6PkcmWTpyuy/+uiCwnErkSz6i2LSBAyDxZQE+T9IAA77a58DtxxjvPuOlJ/TCC1PfKIj/z8HqFYxFnMmmNwwcgM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708720961; c=relaxed/simple; bh=5TYRB9geZwbqkO8y1Zhk51uKaBiKt/CcTaK+FICMgNs=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=UG7UMbfpHf1mkf5VKldpPIrLerlP0OLdt78Btd4mwa8mgSqn8nwG3l2PB6iUDczvAfVQHljWtiaulpM/vLFeJHbmgxNiNkWA2DiQrKDNbEuk3h0weZLep59c6gtAcQDBCM9z5Rq5cYoeVxLnBL+DWikxVslgf2h9WD/9CAVKejc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=I7Hxh3uX; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="I7Hxh3uX" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc6b26ce0bbso1444265276.1 for ; Fri, 23 Feb 2024 12:42:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708720959; x=1709325759; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=VjNX97VdvJmEYHLw9j+I1sJUr3uD5daxjuOHv2NtViI=; b=I7Hxh3uX8BnJaemgx0Njltxn68vW0zYIPjlZ/bw9KPcduCDk80NHhx8k30DSpCh/9d dq2CfWXUjrr1N43UKvhpPlJtS261/DJBWNTulG19Ekfl0r3Ppxy9ZuV33xhMqtUqNzzd +KVXHjDHTzoOKqA4O/Q4lyTz4Icby/+iqMh++l+Pa4fkCKQWMHpibrPMrGjIMjPeJQJF 8D/0Cf+I8Aj9MwsyRgWg85MZs6vwW7PSFdBJ4Ydv0wfeBPC5xwnjFIDp8xPl7rA0WxaY MXYcTfDaT1XiPq5sqiqkZN2jmj41vVR4oINpWmlJ8EyJXql0y9qv9xKb4PXEdgV7n2xO ULNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708720959; x=1709325759; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VjNX97VdvJmEYHLw9j+I1sJUr3uD5daxjuOHv2NtViI=; b=D/JsOFj5TAiCkQbgO7BTfOJpVe7JlVI3CUdLVtw8gVwpeYpJh23KNj4R0pVPn0IRJC VpE27gbhR7mfhivjkmdHjL/4CyeBFpyrPsZ0+IEdPA4FwXMALCVyMaxphg/MAoSvg0EW wih4DUvrY1z11V+DsqF4dkxsK2YwSSRGuFnEs0kx2pFcIAG/Gom3IEOUo2UcAMaECItE FLI3kHR99tW7iZdymQSqISe+APZXnDEBjkVoDFaBLFXFZGQdON6VwFQN094Gcb7j3a0u cSIbGngrYvb9iAfvSp9j1blz7aPKo1dMUhnnE+eh0aJ7SqZVRG0GvjwtKKtiJ3Q8drsw ICmg== X-Gm-Message-State: AOJu0Yydom464nGceDmU9KySN1ux6r9rWkwfD2BBzx5AvCaOWlbyVxUp KoG4QLWJSO7qOCdxTATGtDhBsFyuMfG3zZlbFGhFMkQI3Yzf8z/bVmYrAlbKdmypKEfbIdCPs9m yGA== X-Google-Smtp-Source: AGHT+IFdZpJVi5VhF+3G9bjDUkDjPsA338hhzQ0X8pi1uif6S/kEVgB29+ZuBuPCDHNwZfB8yTq4+HxfzSI= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:69ce:0:b0:dc7:9218:df47 with SMTP id e197-20020a2569ce000000b00dc79218df47mr246758ybc.5.1708720958891; Fri, 23 Feb 2024 12:42:38 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 23 Feb 2024 12:42:27 -0800 In-Reply-To: <20240223204233.3337324-1-seanjc@google.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240223204233.3337324-1-seanjc@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240223204233.3337324-3-seanjc@google.com> Subject: [PATCH 2/8] KVM: SVM: Wrap __svm_sev_es_vcpu_run() with #ifdef CONFIG_KVM_AMD_SEV From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Tom Lendacky , Michael Roth , Alexey Kardashevskiy Compile (and link) __svm_sev_es_vcpu_run() if and only if SEV support is actually enabled. This will allow dropping non-existent 32-bit "support" from __svm_sev_es_vcpu_run() without causing undue confusion. Intentionally don't provide a stub (but keep the declaration), as any sane compiler, even with things like KASAN enabled, should eliminate the call to __svm_sev_es_vcpu_run() since sev_es_guest() unconditionally returns "false" if CONFIG_KVM_AMD_SEV=n. Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/vmenter.S | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kvm/svm/vmenter.S b/arch/x86/kvm/svm/vmenter.S index ee5d5a30da88..7ee363d7517c 100644 --- a/arch/x86/kvm/svm/vmenter.S +++ b/arch/x86/kvm/svm/vmenter.S @@ -291,6 +291,7 @@ SYM_FUNC_START(__svm_vcpu_run) SYM_FUNC_END(__svm_vcpu_run) +#ifdef CONFIG_KVM_AMD_SEV /** * __svm_sev_es_vcpu_run - Run a SEV-ES vCPU via a transition to SVM guest mode * @svm: struct vcpu_svm * @@ -389,3 +390,4 @@ SYM_FUNC_START(__svm_sev_es_vcpu_run) _ASM_EXTABLE(1b, 3b) SYM_FUNC_END(__svm_sev_es_vcpu_run) +#endif /* CONFIG_KVM_AMD_SEV */ From patchwork Fri Feb 23 20:42:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13569966 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB237153509 for ; Fri, 23 Feb 2024 20:42:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708720963; cv=none; b=bCEAxEvbTrh7A8+x0nSxSsKcKJfJDIdp97tcYdfp32DRe6qyaCI6osYpfZxP6r+YoczVTTAU7tyS3FOEnai7RkK6CeP5WzPOBolM7OTxJ19APfpPrsw3AuAGzG+a/+KZh/zguJiDMK6DebBtWmh0gpekJfW0eGW2wtZ3pjCKbKk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708720963; c=relaxed/simple; bh=k0eGgIhqmjJk6wFzrviaHr5FNb9k9KBeDzh45p9EPkE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=gcWVYv/c6Mpyt3jp5eieCfATBdXXvtC5eswmaV76ZX00zMqnLIytVVGdYq4VxIWZlUD9KR6cK1MIhGqSM7cOaW1UiIbkxXZ/34bXdUPFIopbA+jPVgpFNN/nC+R7ZsYDKcx96b8esA9cE1E4tDZItjvAUEceQY9NpyGC+9JrDZw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=dno+02JK; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="dno+02JK" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc6b2682870so1187261276.0 for ; Fri, 23 Feb 2024 12:42:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708720960; x=1709325760; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=WHWPH6O3SBPytu8N+jRZuhsLbq0a353cKtc0xEMWOV0=; b=dno+02JKufZVXMr37vf5CotMKuga5zSxsabS32iTiMM1k56KTsx3vGFZED7Rev4Vfs +530DogWR47+EQxVcqD6z2hrIpOA/zY0PZA78QHRItubM0X/6cLa1wXusMzQJgBs0aLd O7q61K/mAN5EoYVNJqPtL/aPiPeI9UcPLhIMo5jnDekNv7qR38eqdCuyDQt5thpqSBhY rzKWfY8vmpYEi4E6bHfyhY+AF537Ug0pnXmHV4tdK9nyYFc/bXx2gdeT1efBCTWSc4ax wNuL9M/aIazC4eZbuY5JlC/tdK1o6FsLKyI5dqqXDRiZ/IfdSRuWs8mENN79UGl6kSUe dMqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708720960; x=1709325760; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=WHWPH6O3SBPytu8N+jRZuhsLbq0a353cKtc0xEMWOV0=; b=UblAGa4fCfZerpcgDPFBccnQXGSwTC0dKdauLPW//bCj0GMc9C2XuzwjrFv2wFRUIA ClJHd562fIlqmKRd39NjldcnekjtHOD3MmNiRGnYVoOnD1AYfTgSX+ZJeqeO/DKtaksX cBZmrTXin53KaDpsYDmuIFlcDLNgz8bW5StrfE1rgZ0u5CNhQBmRWYXKUKx9p3LVyJNL QcQvzPv6KjFR5CHdAQx199IK9IM1QbCfkdOxceWhaALO8Yin3gVO3NI8+ph4lk+9uMmq nN9grA8qewqyfshiXL7eXUQMtRYigTtLSl/GHctJzH6G6PEAkbTxzP26eWNXsRAPVxxd XFJQ== X-Gm-Message-State: AOJu0YyJwExB1KKUFIkIIIFhbj+JLtn0kFhRW5bsI9f6IFVrRum1Tx92 FJHzpt5mVQCe3D5Q0Z+3bhbkncwWhWAwSKAte7AGkRe60HkmqsHbyzuKJ954aDffqBoVDjFG9z6 tPA== X-Google-Smtp-Source: AGHT+IEs8R1+cXtTADIm679PXjQV+EhmLQgYPjuzJbrMcPnC6qlCVjp69a/NLgbvariU2BnkW2q+mhoIrzo= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:aae5:0:b0:dc7:7ce9:fb4d with SMTP id t92-20020a25aae5000000b00dc77ce9fb4dmr242093ybi.12.1708720960791; Fri, 23 Feb 2024 12:42:40 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 23 Feb 2024 12:42:28 -0800 In-Reply-To: <20240223204233.3337324-1-seanjc@google.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240223204233.3337324-1-seanjc@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240223204233.3337324-4-seanjc@google.com> Subject: [PATCH 3/8] KVM: SVM: Drop 32-bit "support" from __svm_sev_es_vcpu_run() From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Tom Lendacky , Michael Roth , Alexey Kardashevskiy Drop 32-bit "support" from __svm_sev_es_vcpu_run(), as SEV/SEV-ES firmly 64-bit only. The "support" was purely the result of bad copy+paste from __svm_vcpu_run(), which in turn was slightly less bad copy+paste from __vmx_vcpu_run(). Opportunistically convert to unadulterated register accesses so that it's easier (but still not easy) to follow which registers hold what arguments, and when. Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/vmenter.S | 44 +++++++++++--------------------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/arch/x86/kvm/svm/vmenter.S b/arch/x86/kvm/svm/vmenter.S index 7ee363d7517c..0026b4a56d25 100644 --- a/arch/x86/kvm/svm/vmenter.S +++ b/arch/x86/kvm/svm/vmenter.S @@ -298,17 +298,12 @@ SYM_FUNC_END(__svm_vcpu_run) * @spec_ctrl_intercepted: bool */ SYM_FUNC_START(__svm_sev_es_vcpu_run) - push %_ASM_BP -#ifdef CONFIG_X86_64 + push %rbp push %r15 push %r14 push %r13 push %r12 -#else - push %edi - push %esi -#endif - push %_ASM_BX + push %rbx /* * Save variables needed after vmexit on the stack, in inverse @@ -316,39 +311,31 @@ SYM_FUNC_START(__svm_sev_es_vcpu_run) */ /* Accessed directly from the stack in RESTORE_HOST_SPEC_CTRL. */ - push %_ASM_ARG2 + push %rsi /* Save @svm. */ - push %_ASM_ARG1 - -.ifnc _ASM_ARG1, _ASM_DI - /* - * Stash @svm in RDI early. On 32-bit, arguments are in RAX, RCX - * and RDX which are clobbered by RESTORE_GUEST_SPEC_CTRL. - */ - mov %_ASM_ARG1, %_ASM_DI -.endif + push %rdi /* Clobbers RAX, RCX, RDX. */ RESTORE_GUEST_SPEC_CTRL /* Get svm->current_vmcb->pa into RAX. */ - mov SVM_current_vmcb(%_ASM_DI), %_ASM_AX - mov KVM_VMCB_pa(%_ASM_AX), %_ASM_AX + mov SVM_current_vmcb(%rdi), %rax + mov KVM_VMCB_pa(%rax), %rax /* Enter guest mode */ sti -1: vmrun %_ASM_AX +1: vmrun %rax 2: cli /* Pop @svm to RDI, guest registers have been saved already. */ - pop %_ASM_DI + pop %rdi #ifdef CONFIG_RETPOLINE /* IMPORTANT: Stuff the RSB immediately after VM-Exit, before RET! */ - FILL_RETURN_BUFFER %_ASM_AX, RSB_CLEAR_LOOPS, X86_FEATURE_RETPOLINE + FILL_RETURN_BUFFER %rax, RSB_CLEAR_LOOPS, X86_FEATURE_RETPOLINE #endif /* Clobbers RAX, RCX, RDX. */ @@ -364,26 +351,21 @@ SYM_FUNC_START(__svm_sev_es_vcpu_run) UNTRAIN_RET_VM /* "Pop" @spec_ctrl_intercepted. */ - pop %_ASM_BX + pop %rbx - pop %_ASM_BX + pop %rbx -#ifdef CONFIG_X86_64 pop %r12 pop %r13 pop %r14 pop %r15 -#else - pop %esi - pop %edi -#endif - pop %_ASM_BP + pop %rbp RET RESTORE_GUEST_SPEC_CTRL_BODY RESTORE_HOST_SPEC_CTRL_BODY -3: cmpb $0, _ASM_RIP(kvm_rebooting) +3: cmpb $0, kvm_rebooting(%rip) jne 2b ud2 From patchwork Fri Feb 23 20:42:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13569967 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5F5D15531D for ; Fri, 23 Feb 2024 20:42:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708720965; cv=none; b=E+3IifE9bRYWvThQp14dizO8Lf9H3igLsrMTqDxG5uvVAl24BhjQUHhcOvwgg5FZtyIejQq0cApdg1quZ7FSCPPFJbgDeOczSpfAhIYU5/btC6sgaQWWd0OI2b5dHus3EoUYk3s8oRheBgUkx3PapSZhUIoprD8XyahEBYBa9og= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708720965; c=relaxed/simple; bh=I0QVUNXtcgHX8n+zXfP8ri6kLK8vFj5GkBmrqx6hkTs=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=fIlNBtQXCzEHdhHP5PS8ElYxlShrzeO9IfZuwiti1I7UdnThG0czFJN5KTxjIFYdAbT7g4MJud5iOWuBeoF/5Iz0yoHHE5LA8cxuQ15MP6fYX2jGdcVXFLAAj1ac6nJIO0S6wlsiwUA3IB8UOjDIxZ9ecuDO66Zpkj1K4Mq4I3Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=mfei++X/; arc=none smtp.client-ip=209.85.210.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="mfei++X/" Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-6e4e4572980so579827b3a.3 for ; Fri, 23 Feb 2024 12:42:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708720963; x=1709325763; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=5BA83Ml2Mr+6P5rMV7bzjFJqA1AMsjlfbBOavKz4yto=; b=mfei++X/8SGIFDOL2LCuIu1hXggibnEx8AZecEBJ/Vd6TkZzzqo3zsLJyKux5UUYnm H6hLi6WImwNgBh+GxuoebXbCMgQvolOgHTFLBqeaSIJMh22XVTE3SeqF50iY5CW3gKqH /nuJ7exVV/dUt/0y8axQTlobK1/vTLiT0I+bs9AqUFf1OXItxJ/AMG+exoYjzMI7WG7H pisiTybLZR7gFe7n2G2G1G3Uh9azthWDhLmtE3JI2DGqciFVfE6PT//zsX8ExmqUZ+nx qLpNsJ9u42wUFbewIr2hSLu7J/LQovikjBd0RlwFe2TkgwxOr/GgPcj/jCD68ABmlDjj Q6Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708720963; x=1709325763; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5BA83Ml2Mr+6P5rMV7bzjFJqA1AMsjlfbBOavKz4yto=; b=pmtFbuFDO8NqqNcTEcIfhGKKguD8oqHJWnY5xFFLa6wEIIxjVWpdI8HlvC8ACZH0et 4fIzOF+s4LuGTFR7mKSkOknMZmpou+7b/WTyTT5hPYU8zlZ5Emq3lT/XMti4jMXOt9js pm6CsNRqkmPYwBr7kzxH1K5GkX+wB82yOeVD8Af4pcjF2yZuaB+Q/qkimu27PSfREpR7 kkjCZhaukHv13IUNX9f5lCWdDH92DueRvJkkGeC+DR5r8iZsOZ+Qe0kRnoT3AXfWARAD MtONpx6t6ZdQOSZaPOi+uQj6YroMDeUvQ85a0gxvgzfG3oOeeEmSLFaPwePmTg5l0aeu IMYQ== X-Gm-Message-State: AOJu0Yw865omUJMp5DZzjV8xqCFi8DeO+LpeTs4QeXinbUEKKOz1SFOS PX8hp60NIBrnhpAXGInBREQWC/vz+/aquGcazVMrIOGUYHBNuCRMC/AdiTSR2jjiQ2wanq8ccIy peA== X-Google-Smtp-Source: AGHT+IF6noekl4xL/9jHPYxwalCxxEyfgFoPNHuQpPMbIgWGu3MhiabwvcM3s3NwiWHJzCCpsnEGI9goKxU= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a00:179b:b0:6e4:74d9:6a3f with SMTP id s27-20020a056a00179b00b006e474d96a3fmr76652pfg.1.1708720962721; Fri, 23 Feb 2024 12:42:42 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 23 Feb 2024 12:42:29 -0800 In-Reply-To: <20240223204233.3337324-1-seanjc@google.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240223204233.3337324-1-seanjc@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240223204233.3337324-5-seanjc@google.com> Subject: [PATCH 4/8] KVM: SVM: Clobber RAX instead of RBX when discarding spec_ctrl_intercepted From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Tom Lendacky , Michael Roth , Alexey Kardashevskiy POP @spec_ctrl_intercepted into RAX instead of RBX when discarding it from the stack so that __svm_sev_es_vcpu_run() doesn't modify any non-volatile registers. __svm_sev_es_vcpu_run() doesn't return a value, and RAX is already are clobbered multiple times in the #VMEXIT path. This will allowing using the host save area to save/restore non-volatile registers in __svm_sev_es_vcpu_run(). Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/vmenter.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/svm/vmenter.S b/arch/x86/kvm/svm/vmenter.S index 0026b4a56d25..edbaadaacba7 100644 --- a/arch/x86/kvm/svm/vmenter.S +++ b/arch/x86/kvm/svm/vmenter.S @@ -350,8 +350,8 @@ SYM_FUNC_START(__svm_sev_es_vcpu_run) */ UNTRAIN_RET_VM - /* "Pop" @spec_ctrl_intercepted. */ - pop %rbx + /* "Pop" and discard @spec_ctrl_intercepted. */ + pop %rax pop %rbx From patchwork Fri Feb 23 20:42:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13569968 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E3C1157E86 for ; Fri, 23 Feb 2024 20:42:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708720967; cv=none; b=FJtJMUw9hGrdEF0YfqSGpIB1TZi1cgc+/J5QCjF0Oure4TsdbHFM6TW5+ns2XuPGr1lrKYIDc3tmIZCNdcb73baqg6EelBXOAh7JqCQI4z8L1X+Vt9vnA0T5FEWRKuFvNM7YZ7+4AAC3rXL285BZzmzBlTE9bVnh/z23o0egei4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708720967; c=relaxed/simple; bh=2NQqn0GS1NXkZhFdQnHQDhlZap/bPRB2/FTisNgRF48=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ASyAgHHwn1YT9an3mOHlrmlcHRF4dwJl7TVL/w31WfZmOuZRG0REDyqvfCeCfVjIkaD+M8ljOsO8AIcDywfELb7SBlDlbU87yp91GXMaNW5zeNV9M9ifEY+5Im16DH2+5G2/bn79TQ+ABwHVZI80j77KTBmQ0KJP2ux463FXRxI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=CmekOdEZ; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="CmekOdEZ" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6087ffdac8cso13957957b3.2 for ; Fri, 23 Feb 2024 12:42:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708720964; x=1709325764; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=fjPJ3Hja7aXkfyUdgxA5xTLuvAk9amyqKFMcOEhsGqM=; b=CmekOdEZhBlSR+m+qkvetN4vXy6aAs4K2Aqz7+dBGhTrSRGmVUfZcCJCaLRS6Tg1EQ +AqV9BdVyxHw7Jh6D1GOnbKsjjy1n6HknPWPbMCAGizEakeSVkNi/TY6W4Xo0tOVZb9Y BWupji0dF0NJDVzfNEvYfc1zQxDFrXOue+lO6dTtT/bftQiurEtQ3BbOeEo+CWEXA/8K TMCiEJygm01gxqW5BTqTU/qfSAmul6B3MnNlHotgMdPwLz+f25jNcxep49Hduc8CZU/9 h/sX7rS+e6MDCaTX697ZC/gOKrv2VbiqVhSzL5CTiWHIUbzSNbJq5ld/8t2XfSiOmhXM 9pdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708720964; x=1709325764; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=fjPJ3Hja7aXkfyUdgxA5xTLuvAk9amyqKFMcOEhsGqM=; b=DqbDOEHQKiJgzzGvqcLvq/f3PGa9DvxQpHHuuDXR0jXB7VOZwhFIzoHSEeOCx/xWdm W37ajxQabKqOmuYTzvt+BJVzdcloDATCzF3o9j8EX/nCuD9hbL+oyUHvvVTFK/eL0Sdp 8aNeHxoD6yhZ3aNDFmSl0buB11vLNfupSE1Dx+NdmlGAkGacd3iz6l/mVXLkzHFxHV9Z TuqsxRF/s72YsjpYGwc7WUde6rpkdVOm7SAy8sBvLI4z03kNjoRXkLHNudYZKZP7Wbkd q26Y9iuU4BvZGEusJ0TIglKGj/1J1RNnaxfhQR/ejiYiePqESV0yuRNwwE5LCMOTZTCJ FyKA== X-Gm-Message-State: AOJu0YzNMxbz2MkDKIpx2+/hVlq2Vj2OA9HEjYCOLu72b4N3BKiI9WJ1 XzPutUqlCPJQAWG3mA4ej5UarMDYJgTP/FsunPQ+t0R84tKZAmD0/7TJf75pbQUH6LX9jEWQF8y h1A== X-Google-Smtp-Source: AGHT+IF38vTRLUiuDrGGzTvX81aATDA8TANDbUdAfA3ms+j3X+FiOVp6jsSKOrh+1hU5miP3ns29lCgI6fs= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:1243:b0:dcd:3172:7265 with SMTP id t3-20020a056902124300b00dcd31727265mr244887ybu.8.1708720964754; Fri, 23 Feb 2024 12:42:44 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 23 Feb 2024 12:42:30 -0800 In-Reply-To: <20240223204233.3337324-1-seanjc@google.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240223204233.3337324-1-seanjc@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240223204233.3337324-6-seanjc@google.com> Subject: [PATCH 5/8] KVM: SVM: Save/restore non-volatile GPRs in SEV-ES VMRUN via host save area From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Tom Lendacky , Michael Roth , Alexey Kardashevskiy Use the host save area to save/restore non-volatile (callee-saved) registers in __svm_sev_es_vcpu_run() to take advantage of hardware loading all registers from the save area on #VMEXIT. KVM still needs to save the registers it wants restored, but the loads are handled automatically by hardware. Aside from less assembly code, letting hardware do the restoration means stack frames are preserved for the entirety of __svm_sev_es_vcpu_run(). Opportunistically add a comment to call out why @svm needs to be saved across VMRUN->#VMEXIT, as it's not easy to decipher that from the macro hell. Cc: Tom Lendacky Cc: Michael Roth Cc: Alexey Kardashevskiy Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/svm.c | 17 +++++++++------- arch/x86/kvm/svm/svm.h | 3 ++- arch/x86/kvm/svm/vmenter.S | 41 +++++++++++++++++++++----------------- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index e90b429c84f1..e7c8a48e36eb 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1503,6 +1503,11 @@ static void svm_vcpu_free(struct kvm_vcpu *vcpu) __free_pages(virt_to_page(svm->msrpm), get_order(MSRPM_SIZE)); } +static struct sev_es_save_area *sev_es_host_save_area(struct svm_cpu_data *sd) +{ + return page_address(sd->save_area) + 0x400; +} + static void svm_prepare_switch_to_guest(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm = to_svm(vcpu); @@ -1519,12 +1524,8 @@ static void svm_prepare_switch_to_guest(struct kvm_vcpu *vcpu) * or subsequent vmload of host save area. */ vmsave(sd->save_area_pa); - if (sev_es_guest(vcpu->kvm)) { - struct sev_es_save_area *hostsa; - hostsa = (struct sev_es_save_area *)(page_address(sd->save_area) + 0x400); - - sev_es_prepare_switch_to_guest(hostsa); - } + if (sev_es_guest(vcpu->kvm)) + sev_es_prepare_switch_to_guest(sev_es_host_save_area(sd)); if (tsc_scaling) __svm_write_tsc_multiplier(vcpu->arch.tsc_scaling_ratio); @@ -4101,6 +4102,7 @@ static fastpath_t svm_exit_handlers_fastpath(struct kvm_vcpu *vcpu) static noinstr void svm_vcpu_enter_exit(struct kvm_vcpu *vcpu, bool spec_ctrl_intercepted) { + struct svm_cpu_data *sd = per_cpu_ptr(&svm_data, vcpu->cpu); struct vcpu_svm *svm = to_svm(vcpu); guest_state_enter_irqoff(); @@ -4108,7 +4110,8 @@ static noinstr void svm_vcpu_enter_exit(struct kvm_vcpu *vcpu, bool spec_ctrl_in amd_clear_divider(); if (sev_es_guest(vcpu->kvm)) - __svm_sev_es_vcpu_run(svm, spec_ctrl_intercepted); + __svm_sev_es_vcpu_run(svm, spec_ctrl_intercepted, + sev_es_host_save_area(sd)); else __svm_vcpu_run(svm, spec_ctrl_intercepted); diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index 8ef95139cd24..b98cced44e48 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -697,7 +697,8 @@ void sev_es_unmap_ghcb(struct vcpu_svm *svm); /* vmenter.S */ -void __svm_sev_es_vcpu_run(struct vcpu_svm *svm, bool spec_ctrl_intercepted); +void __svm_sev_es_vcpu_run(struct vcpu_svm *svm, bool spec_ctrl_intercepted, + struct sev_es_save_area *hostsa); void __svm_vcpu_run(struct vcpu_svm *svm, bool spec_ctrl_intercepted); #define DEFINE_KVM_GHCB_ACCESSORS(field) \ diff --git a/arch/x86/kvm/svm/vmenter.S b/arch/x86/kvm/svm/vmenter.S index edbaadaacba7..e92953427100 100644 --- a/arch/x86/kvm/svm/vmenter.S +++ b/arch/x86/kvm/svm/vmenter.S @@ -292,23 +292,35 @@ SYM_FUNC_START(__svm_vcpu_run) SYM_FUNC_END(__svm_vcpu_run) #ifdef CONFIG_KVM_AMD_SEV + + +#ifdef CONFIG_X86_64 +#define SEV_ES_GPRS_BASE 0x300 +#define SEV_ES_RBX (SEV_ES_GPRS_BASE + __VCPU_REGS_RBX * WORD_SIZE) +#define SEV_ES_RBP (SEV_ES_GPRS_BASE + __VCPU_REGS_RBP * WORD_SIZE) +#define SEV_ES_R12 (SEV_ES_GPRS_BASE + __VCPU_REGS_R12 * WORD_SIZE) +#define SEV_ES_R13 (SEV_ES_GPRS_BASE + __VCPU_REGS_R13 * WORD_SIZE) +#define SEV_ES_R14 (SEV_ES_GPRS_BASE + __VCPU_REGS_R14 * WORD_SIZE) +#define SEV_ES_R15 (SEV_ES_GPRS_BASE + __VCPU_REGS_R15 * WORD_SIZE) +#endif + /** * __svm_sev_es_vcpu_run - Run a SEV-ES vCPU via a transition to SVM guest mode * @svm: struct vcpu_svm * * @spec_ctrl_intercepted: bool */ SYM_FUNC_START(__svm_sev_es_vcpu_run) - push %rbp - push %r15 - push %r14 - push %r13 - push %r12 - push %rbx - /* - * Save variables needed after vmexit on the stack, in inverse - * order compared to when they are needed. + * Save non-volatile (callee-saved) registers to the host save area. + * Except for RAX and RSP, all GPRs are restored on #VMEXIT, but not + * saved on VMRUN. */ + mov %rbp, SEV_ES_RBP (%rdx) + mov %r15, SEV_ES_R15 (%rdx) + mov %r14, SEV_ES_R14 (%rdx) + mov %r13, SEV_ES_R13 (%rdx) + mov %r12, SEV_ES_R12 (%rdx) + mov %rbx, SEV_ES_RBX (%rdx) /* Accessed directly from the stack in RESTORE_HOST_SPEC_CTRL. */ push %rsi @@ -316,7 +328,7 @@ SYM_FUNC_START(__svm_sev_es_vcpu_run) /* Save @svm. */ push %rdi - /* Clobbers RAX, RCX, RDX. */ + /* Clobbers RAX, RCX, RDX (@hostsa). */ RESTORE_GUEST_SPEC_CTRL /* Get svm->current_vmcb->pa into RAX. */ @@ -338,7 +350,7 @@ SYM_FUNC_START(__svm_sev_es_vcpu_run) FILL_RETURN_BUFFER %rax, RSB_CLEAR_LOOPS, X86_FEATURE_RETPOLINE #endif - /* Clobbers RAX, RCX, RDX. */ + /* Clobbers RAX, RCX, RDX, consumes RDI (@svm). */ RESTORE_HOST_SPEC_CTRL /* @@ -353,13 +365,6 @@ SYM_FUNC_START(__svm_sev_es_vcpu_run) /* "Pop" and discard @spec_ctrl_intercepted. */ pop %rax - pop %rbx - - pop %r12 - pop %r13 - pop %r14 - pop %r15 - pop %rbp RET RESTORE_GUEST_SPEC_CTRL_BODY From patchwork Fri Feb 23 20:42:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13569969 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1791158D69 for ; Fri, 23 Feb 2024 20:42:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708720970; cv=none; b=JNn5cFaz/1OZoxyNfBRmplKsWeUW3SUQ53VwVbhvmp0f/uTg9rsY+Msew9g9JsuVTTRl+MVwxaZTAzbmB5IJBaSeWQ9PutGmeef5Ch0fEGIzURKzgKbHL1kA78yhRMpQdfpIpkJUTslW+8jp6a9vE6jeM6qry2WPSbeFU1JZZ8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708720970; c=relaxed/simple; bh=l0zkmGZQWE9+kQETtRT0ImK1JoiFu1GlHAy5QX+NL98=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=qlKnnQ+e6/rL1yQ3VUhhVwdg8ianvg+m2LUn+Yl7oMXat6gOmbZRfEIfhtr2O5WX24O7DHLL+sAD2+bedytZushCTJo13nVcmQrkjxr5wwQD/Mhb//CO+S1d5lGmSt9koOgfbpQRGuBx2W7rUmE0RYYTZ1MFbBX+nRss3h2sk8k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=t8oFKth8; arc=none smtp.client-ip=209.85.215.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="t8oFKth8" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-5dc91de351fso925412a12.0 for ; Fri, 23 Feb 2024 12:42:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708720968; x=1709325768; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=eMiAiix9phUQ/h1sG+JlRQvWAIP+ZL2r3XfvgJSywGA=; b=t8oFKth8zniXokoLiWVauCK3SM+RLdkOE9fVqUWEuIkoEUL9qn7AZUEdrkbEtoxVxu ElmJoa+oPiHmrhRDZGYWcAnqDl8HFYb5OVT7HPyFfBD/lyCG2xZsIgumUdFzOdkjVkjT 069/y+FMsRy+mzxdw6kk8fxheM3Mhzith3Wh/xURXW8t/5MwRHvEJSO/2uDVCdoTznBx +HOLEH1J+H/Kt69LCOiVgSETRLMZ0qGlbq6+bBvVpIUmexSiOUsKP8ze1HA0H13VBlF3 Dk+fa9yN5MwBvIZPVSdVnwbuFkAsC20Fe1iq427x6wh86BtIkKvzHLVPgUCxq/sJhg7g mwVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708720968; x=1709325768; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=eMiAiix9phUQ/h1sG+JlRQvWAIP+ZL2r3XfvgJSywGA=; b=gyI+1w5fVpoDODH8BYgCbFGRlXQgGLyIo8sIBxiNPxcgVBlNqiQX06/peHNnflxL2F OXk1sDsunLCJh27RgOCQYXGafIKxqeGw8hSf11eWjCi+Nvoh8kOTybYVHH1fQDNlqums kmNDRfC9FpjnHdgq3DpDKIX5hg/NDZOofIexvdHGhq/JjMGd3sd0o6nWt9I0fHaw4nwu JhOo8ZwIDtCBpYpphfFTf5Nd0k8S9pyodYVV5Sa7d68PBmlFfqRw2qH/ThBanhQG9sy4 7/xpRdVCZNIj2PYLjcSI1fi7Ih7xFQ8hkqYAhdZhnLRfERYGM0ww1dWaLJzu/wzjZrt+ UUGA== X-Gm-Message-State: AOJu0YzuKcXEIKmObmxUH1nNYoqTKxCgTXYnh5he5x0vb4d7zKmlGCaD eV+3QKC6ZiNpnmYUCSVtuXC014TM4NGI32zrW+Q1E/08M/g8vMSO3u55/DzRGalO6l1eeYwDFhP ExA== X-Google-Smtp-Source: AGHT+IGwnheLLt11GCgq5bE9Gg3yzwQwcKlYIU9oJNz7WYe1wgIud5ZyeG1jDhmi6OGPwB1nWqKwpU0ePoM= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a63:201b:0:b0:5e4:2b26:960a with SMTP id g27-20020a63201b000000b005e42b26960amr2263pgg.4.1708720967712; Fri, 23 Feb 2024 12:42:47 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 23 Feb 2024 12:42:31 -0800 In-Reply-To: <20240223204233.3337324-1-seanjc@google.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240223204233.3337324-1-seanjc@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240223204233.3337324-7-seanjc@google.com> Subject: [PATCH 6/8] KVM: SVM: Save/restore args across SEV-ES VMRUN via host save area From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Tom Lendacky , Michael Roth , Alexey Kardashevskiy Use the host save area to preserve volatile registers that are used in __svm_sev_es_vcpu_run() to access function parameters after #VMEXIT. Like saving/restoring non-volatile registers, there's no reason not to take advantage of hardware restoring registers on #VMEXIT, as doing so shaves a few instructions and the save area is going to be accessed no matter what. Converting all register save/restore code to use the host save area also make it easier to follow the SEV-ES VMRUN flow in its entirety, as opposed to having a mix of stack-based versus host save area save/restore. Add a parameter to RESTORE_HOST_SPEC_CTRL_BODY so that the SEV-ES path doesn't need to write @spec_ctrl_intercepted to memory just to play nice with the common macro. Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/vmenter.S | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/arch/x86/kvm/svm/vmenter.S b/arch/x86/kvm/svm/vmenter.S index e92953427100..48cdba47622c 100644 --- a/arch/x86/kvm/svm/vmenter.S +++ b/arch/x86/kvm/svm/vmenter.S @@ -67,7 +67,7 @@ "", X86_FEATURE_V_SPEC_CTRL 901: .endm -.macro RESTORE_HOST_SPEC_CTRL_BODY +.macro RESTORE_HOST_SPEC_CTRL_BODY spec_ctrl_intercepted:req 900: /* Same for after vmexit. */ mov $MSR_IA32_SPEC_CTRL, %ecx @@ -76,7 +76,7 @@ * Load the value that the guest had written into MSR_IA32_SPEC_CTRL, * if it was not intercepted during guest execution. */ - cmpb $0, (%_ASM_SP) + cmpb $0, \spec_ctrl_intercepted jnz 998f rdmsr movl %eax, SVM_spec_ctrl(%_ASM_DI) @@ -269,7 +269,7 @@ SYM_FUNC_START(__svm_vcpu_run) RET RESTORE_GUEST_SPEC_CTRL_BODY - RESTORE_HOST_SPEC_CTRL_BODY + RESTORE_HOST_SPEC_CTRL_BODY (%_ASM_SP) 10: cmpb $0, _ASM_RIP(kvm_rebooting) jne 2b @@ -298,6 +298,8 @@ SYM_FUNC_END(__svm_vcpu_run) #define SEV_ES_GPRS_BASE 0x300 #define SEV_ES_RBX (SEV_ES_GPRS_BASE + __VCPU_REGS_RBX * WORD_SIZE) #define SEV_ES_RBP (SEV_ES_GPRS_BASE + __VCPU_REGS_RBP * WORD_SIZE) +#define SEV_ES_RSI (SEV_ES_GPRS_BASE + __VCPU_REGS_RSI * WORD_SIZE) +#define SEV_ES_RDI (SEV_ES_GPRS_BASE + __VCPU_REGS_RDI * WORD_SIZE) #define SEV_ES_R12 (SEV_ES_GPRS_BASE + __VCPU_REGS_R12 * WORD_SIZE) #define SEV_ES_R13 (SEV_ES_GPRS_BASE + __VCPU_REGS_R13 * WORD_SIZE) #define SEV_ES_R14 (SEV_ES_GPRS_BASE + __VCPU_REGS_R14 * WORD_SIZE) @@ -322,11 +324,12 @@ SYM_FUNC_START(__svm_sev_es_vcpu_run) mov %r12, SEV_ES_R12 (%rdx) mov %rbx, SEV_ES_RBX (%rdx) - /* Accessed directly from the stack in RESTORE_HOST_SPEC_CTRL. */ - push %rsi - - /* Save @svm. */ - push %rdi + /* + * Save volatile registers that hold arguments that are needed after + * #VMEXIT (RDI=@svm and RSI=@spec_ctrl_intercepted). + */ + mov %rdi, SEV_ES_RDI (%rdx) + mov %rsi, SEV_ES_RSI (%rdx) /* Clobbers RAX, RCX, RDX (@hostsa). */ RESTORE_GUEST_SPEC_CTRL @@ -342,15 +345,12 @@ SYM_FUNC_START(__svm_sev_es_vcpu_run) 2: cli - /* Pop @svm to RDI, guest registers have been saved already. */ - pop %rdi - #ifdef CONFIG_RETPOLINE /* IMPORTANT: Stuff the RSB immediately after VM-Exit, before RET! */ FILL_RETURN_BUFFER %rax, RSB_CLEAR_LOOPS, X86_FEATURE_RETPOLINE #endif - /* Clobbers RAX, RCX, RDX, consumes RDI (@svm). */ + /* Clobbers RAX, RCX, RDX, consumes RDI (@svm) and RSI (@spec_ctrl_intercepted). */ RESTORE_HOST_SPEC_CTRL /* @@ -362,13 +362,10 @@ SYM_FUNC_START(__svm_sev_es_vcpu_run) */ UNTRAIN_RET_VM - /* "Pop" and discard @spec_ctrl_intercepted. */ - pop %rax - RET RESTORE_GUEST_SPEC_CTRL_BODY - RESTORE_HOST_SPEC_CTRL_BODY + RESTORE_HOST_SPEC_CTRL_BODY %sil 3: cmpb $0, kvm_rebooting(%rip) jne 2b From patchwork Fri Feb 23 20:42:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13569970 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2141158D8C for ; Fri, 23 Feb 2024 20:42:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708720972; cv=none; b=iSA0NQ7PzGXW6Yas8wf46Dv2j1Q/avClWySlpwl1n7F8M6RuYUNBQ7tOXssLQxGhktEWppNnnPHAFEXD7aiUzwudYVbNwMlnKgp4ATSGKaL1JzkhCMywpgO9RtDihS0lOlclEvLBttjSc+8gPIChgCERWjjMJzGbfODpTyL1zHM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708720972; c=relaxed/simple; bh=x8JOCHKvKb4ozY0sAwrZiWMcGVvJkG+syIMQG5Dq5oA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=XE1kGwoOYdI3fLvJrtpGAdlTwL7e8nnfk67gZNzEv5KaaqzO2Pa1Lj9OSE1Uby5n1575JG1J2ylEknR027OReNHRvSk9uejvbxhWySrYA+pgEocik3o0oWmIFCC/FCWKp3rqu/4UDOffGGw+lgc0QSZ1xbCPJ0ePUZRjb0JZo9A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=bpT+2oIB; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="bpT+2oIB" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dcbfe1a42a4so2328715276.2 for ; Fri, 23 Feb 2024 12:42:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708720970; x=1709325770; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=FfzNCmRZ0S/1zY2q7LR3gyLGd166iHY+ytisyKJMCXE=; b=bpT+2oIBtxQEZ5sHzyTYn58ZEVbChWKoqeyVU7YgevVPbxsTMBbkFVxnBJ2vrYKRED QVN4vsNproJH7drfX9lXIMKf5c1rouM4YcdATbY/b4sWyk/Q1ZzxlWMvoS80slMAGfra 37omCqmeSOl548rP/Zdrj6j3fNT3aguQ97cFoprNR1E4U3MB1Q65cG7ycfMx8R7UcXLL NEXu2JUzFVQ6K32SstHAn4i5RWT9etYIDGIrn6YmotxX9sd8boKnROT2pkzCad9T+Te1 JavvoSrkDBcpSRHGVAGbc5a3rngICnIHoGwNbGY6qNJ64a+CW4XuLMDVLqMzIa4W9nyL D5CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708720970; x=1709325770; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FfzNCmRZ0S/1zY2q7LR3gyLGd166iHY+ytisyKJMCXE=; b=vJGhjC0yklDo0mUkv7hIF0BvKG32SoXOS3Jrym/xyl+2n8k2goH7AzqJhb/NsfWEam RFEbQB6VdirEIVG5byI8/BwLBghA8ynrxOD2KOYr71CVqWkoO2TrwgFTz2C4rAwozYBE X3gCNnaVStt+ng1VS1kdjIFiyPU9BCcdNE3LknTMqAUiR5li50LHgIZUzDbvCuKYXKx1 Y95XtR3nkbwnWuIerbUZV88Bgt0keodo1LCDQymaZmKQeOHnbG6bV7hCI7NjwUc8bQgC FKfGTiQXEl5TleFHw4oNzF1BrUbq2k1REyNjKJhFr/jGY2dVtdhJjwe5fY18rA5eh+LV eh5Q== X-Gm-Message-State: AOJu0Yy1fbokyd7UPBGZostpxSr+oP4/VhOJ7NtQk7hPAgaxu38gWU0d 5ACpfU3zSh9aaHlVw8syV54DoTmXYo+nW4Bz/BXCUbcsaSgL07adxQYtlfVkolGrWWDusuzsacF ALA== X-Google-Smtp-Source: AGHT+IGV/hthBaiJp1W+WKWwI6YRWoUvbR1xriGM2Y9FcbsRPxmHxnvvDAebYds6DGtRf3myzVI02QFezT4= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:2602:b0:dc6:519b:5425 with SMTP id dw2-20020a056902260200b00dc6519b5425mr242656ybb.11.1708720969888; Fri, 23 Feb 2024 12:42:49 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 23 Feb 2024 12:42:32 -0800 In-Reply-To: <20240223204233.3337324-1-seanjc@google.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240223204233.3337324-1-seanjc@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240223204233.3337324-8-seanjc@google.com> Subject: [PATCH 7/8] KVM: SVM: Create a stack frame in __svm_sev_es_vcpu_run() From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Tom Lendacky , Michael Roth , Alexey Kardashevskiy Now that KVM uses the host save area to context switch RBP, i.e. preserves RBP for the entirety of __svm_sev_es_vcpu_run(), create a stack frame using the standared FRAME_{BEGIN,END} macros. Note, __svm_sev_es_vcpu_run() is subtly not a leaf function as it can call into ibpb_feature() via UNTRAIN_RET_VM. Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/vmenter.S | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kvm/svm/vmenter.S b/arch/x86/kvm/svm/vmenter.S index 48cdba47622c..5461c23ee762 100644 --- a/arch/x86/kvm/svm/vmenter.S +++ b/arch/x86/kvm/svm/vmenter.S @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include "kvm-asm-offsets.h" @@ -312,6 +313,8 @@ SYM_FUNC_END(__svm_vcpu_run) * @spec_ctrl_intercepted: bool */ SYM_FUNC_START(__svm_sev_es_vcpu_run) + FRAME_BEGIN + /* * Save non-volatile (callee-saved) registers to the host save area. * Except for RAX and RSP, all GPRs are restored on #VMEXIT, but not @@ -362,6 +365,7 @@ SYM_FUNC_START(__svm_sev_es_vcpu_run) */ UNTRAIN_RET_VM + FRAME_END RET RESTORE_GUEST_SPEC_CTRL_BODY From patchwork Fri Feb 23 20:42:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13569971 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F07E1159583 for ; Fri, 23 Feb 2024 20:42:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708720974; cv=none; b=OfVdzMiyZb283/62jOOx4C5q6qYRCxKx43VedwGFfhiFJ5JeEcQI3VMZn9BTTcNjrU7hX3YXKwWDOqey/W5BzPDT7y/jVkUPFTpANhEPOzaQL41GsTlMXI1xyhNpeu5R8jPuo92lSgS9eEqolrrABQRY/4PnD1y3fShzUDMqMvw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708720974; c=relaxed/simple; bh=7J6KDtGQ/ff8P3w9jb/vWmofOgEnYMuO6+24o5qqEFQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=r6qP4ABFkyxSFB/FFRrD1RYvsHFA/+DeM44bygU51vqMeWCosUpkpCldmo9REZpm0neQCzN24QEcE84bxTGSvvH4z96sUaGdwssoGNSUG+qsShEtTjzZc6OWdU9kqhYjsWPT86NXmZ3xdUzggDlsURViJy36nrJFFU4/iYIscTU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=4nQsW9sa; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="4nQsW9sa" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-60832a48684so19215377b3.1 for ; Fri, 23 Feb 2024 12:42:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708720972; x=1709325772; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=vufYXRT9nLolRxc38rSYg/MmpkjAZM5KmaatkmS8vks=; b=4nQsW9sa4h4EWu7++5cltY8XMcbWe5A10jC/XMx5DneIDsQTOYtm6DkPDnd2pWH0ZK 6UJNSmbqSwj6OUVHqhWjcM4a9FUmKhINnBmt1spcRxqkF4NRn77DAvu5orh2bbAOehVH WEBgkHjoia0ykJpjFKKW6mYIfnaP58TTvDwe3kz/CubNhAdoQbujUtkTeS3EpZY17Brz 7yXExos4ZP2qSUumMeNfsc67UZ23RDMEfst2NNu+KT+BA1xMMbsJ8d/398VH2LYV1jyS h20rEhHK5DAnya4IICVWgo66y6A27VBqJS7glRW+qrrGJ9pfyKLyfytz8lPu3eFx1LUw XaAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708720972; x=1709325772; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vufYXRT9nLolRxc38rSYg/MmpkjAZM5KmaatkmS8vks=; b=cyaJiK+m998M73y3vmjzx+Mu/EtMNaZsgM7fezir7vzwPUQMkAqBYuSE7JbfLt0Yjo oI0digJoBjbY38xIbG3c6FbhS5itYjJBLjkiyBbMR3aOvffvzzAAHLLyXSpg62+NlhyV islOMiX/NI7/BXV6dMmFFpj+kzy5kH1tfgsxf+FAJ2VNMXzDnQpB+mxelIsicHjitxEC 3iYGn0J7RiAbvVD3ACysNysc7wZNO2ekHdvxsuR6L52B32LJ9w/L/7qkQIEspWwHm65q kiVAoIVOV4u+XJzFcLelQp3kzbm0YtrrGUcblV28H+q0WVwQmyOBVUm71OwKRwZusGj3 nrFQ== X-Gm-Message-State: AOJu0YwLOFi2V6/2ap8g/c4BaNQlKfzuklVTavdyyOd7VAu6TDzFoaY1 Is+j3+PypsZzlBcbeokyz/OMVpGqfOOVdYyhl1MD+70WISYInjUXo6BiziU5IW8QWXaxPnaojKj Zzw== X-Google-Smtp-Source: AGHT+IGkwBo3XXrPKmyWtpC730sYPRHOW/RuUbF4N0xhpzdlXJuc/UO48jdXDpjR452hjzguUMHMf64EmkI= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:8452:0:b0:608:cde3:107b with SMTP id u79-20020a818452000000b00608cde3107bmr131247ywf.2.1708720971999; Fri, 23 Feb 2024 12:42:51 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 23 Feb 2024 12:42:33 -0800 In-Reply-To: <20240223204233.3337324-1-seanjc@google.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240223204233.3337324-1-seanjc@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240223204233.3337324-9-seanjc@google.com> Subject: [PATCH 8/8] KVM: x86: Stop compiling vmenter.S with OBJECT_FILES_NON_STANDARD From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Tom Lendacky , Michael Roth , Alexey Kardashevskiy Stop compiling vmenter.S with OBJECT_FILES_NON_STANDARD to skip objtool's stack validation now that __svm_vcpu_run() and __svm_sev_es_vcpu_run() create stack frames (thoughthe former's effectiveness is dubious). Note, due to a quirk in how OBJECT_FILES_NON_STANDARD is handled by the build system, this also affects vmx/vmenter.S. But __vmx_vcpu_run() already plays nice with frame pointers, i.e. it was collateral damage when commit 7f4b5cde2409 ("kvm: Disable objtool frame pointer checking for vmenter.S") added the OBJECT_FILES_NON_STANDARD hack-a-fix. Link: https://lore.kernel.org/all/20240217055504.2059803-1-masahiroy@kernel.org Signed-off-by: Sean Christopherson --- arch/x86/kvm/Makefile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile index 475b5fa917a6..addc44fc7187 100644 --- a/arch/x86/kvm/Makefile +++ b/arch/x86/kvm/Makefile @@ -3,10 +3,6 @@ ccflags-y += -I $(srctree)/arch/x86/kvm ccflags-$(CONFIG_KVM_WERROR) += -Werror -ifeq ($(CONFIG_FRAME_POINTER),y) -OBJECT_FILES_NON_STANDARD_vmenter.o := y -endif - include $(srctree)/virt/kvm/Makefile.kvm kvm-y += x86.o emulate.o i8259.o irq.o lapic.o \