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: 205658 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp835368dyb; Fri, 23 Feb 2024 12:45:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWG4HoDaX2B/1XTBXd3TKavw+cjuLkVtJkEXxfX7pjd1BaDzUGc+ensUn0v/GKFGGUr/2jZLalZwOmjxZ4FvDGe5IGPJQ== X-Google-Smtp-Source: AGHT+IFMylSWg6psp+Rhibx32QRJyUOqbkBqJ9DG+ec9tXdDeofzMntXOX5sQMwtin7D2IDKxlWk X-Received: by 2002:a05:6214:19e3:b0:68f:cdf1:76b4 with SMTP id q3-20020a05621419e300b0068fcdf176b4mr1265770qvc.43.1708721141733; Fri, 23 Feb 2024 12:45:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708721141; cv=pass; d=google.com; s=arc-20160816; b=fvWqFPEaqTxxzP5bk8kWATcHNi6gYwfdNa9klIzSHKllOLh7brzr6HfIH3ga3uzF1L u/On3v6mRls8MzAL5/rm5Z6X78bBl8cbJUTebxwvkTSjPl70aTTMsPWQjCblJoDUyOJK ADLf1snPyByBNjLnhW7jlK9JPdgvH2P2ArXSRfV4tYisppc4iwP+98+jiJTdYZoWG/Zh qLDGqQNQjq/+DVxqr4QUseK+3ASwI2ES0fOVTk890PUess+0RBlKmMUoevJXb5K+6iIw BVf9gFEj7Um2GRaEaqP8XGEJbDPDdiL9SvMRkemXzdbRyZtWcFbfL3BmwlDg1hK+GZMb xNMw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :reply-to:dkim-signature; bh=d647qV5YXXlk1eKRQGMECxhpXnyYK5AYh5qfDVrkHVc=; fh=JwAaPbWMs/qS/X5pd8dDgM+/VbHKUU8svsSuBqRpQ+U=; b=Zeueqfwb2AP2osTVCIZY7QJy1fTDlUq5Gn7IZ5cUp8ua5W5gtviCU9Y83UYvAjyYXB yFWIOHwM2S8dEBe3nnE2kISkj2WgL9lLZi99iTOI03uXPA3b37Z6QfgGfjutrVW3/Zjm iM0tqb94bFgZbci3247d4NWl73jJ0wSt0MyA5xyl1YKqCtfmTrb2jwInPpi43/dZXRTF ZUNOiwAAUm0sOFPYDXNHttbAj3YtbTpnLdq0+EZOiF4lKoqvfLmqPq84EGpT/aKhyLDN 0UAtM8vQxh/W/Lv1IqF9IJZ3qLuQJdzD0akTpBKyWvICWVY21I9bGmtS30BLzsDQllyH BwIA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=RyOWud10; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-79128-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79128-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id m10-20020a0562141bca00b0068fac70696csi5903622qvc.4.2024.02.23.12.45.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 12:45:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79128-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=RyOWud10; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-79128-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79128-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C22411C25357 for ; Fri, 23 Feb 2024 20:45:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC408153BC7; Fri, 23 Feb 2024 20:42:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="RyOWud10" Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 E32BE14938A for ; Fri, 23 Feb 2024 20:42:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708720959; cv=none; b=Rwhmaci8UyU5+eDE0ZHoJ8PI9ys5/9GJjs7viXhA+K9jvywtnOQDVh8qbYmZckV43qGCPb6SSNtEmJHTRtZKCGTBLzmNbAreBkKAz09mL0//+Fa2EIZZJeoNlGK8P0qUoC9VpaaqyVH4mkh3T7CsLtLf3135uBN50EiyMDm31Gs= 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.74 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 Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-29902c06980so1010288a91.2 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=gLGpzefR1sK7BQtJzLxH0wwiM6V1soAB7F+o5jMfK190dzKDC7s+L728DoUyS+31gK 96FX0wTjHlWf/RlCO8a4Bw28YnvpEdNZ19BsvGfhv2+l2dJ+g10vMO7FFoycazMpcc37 M1nUluKoR7zVI3pRjpvNhQVFBGbdj7X5usLR5imk7abmSDav0Vj3U/aKWIB7RHh01AzO 2RQvdA8U5VZKlgDD03uW+sllBynfPxd8ggASYLwe1Z0K5pOtrpIfNx0LpXthqjnFrmxj hLwJ8PtN4c6A9Xu80DRUagIiNJoE7yxUglJFXQTSgjyU95NXXUb3boPyuGnXLm/YOWYP LW7Q== X-Forwarded-Encrypted: i=1; AJvYcCVXQQpm4qIg6RAqUqDDSUsiIwM2O/FZLn9zj3lNZbxEPHg3su0Lcfg66E/pVICKUFzN4qz3XA2BpfP6vX/OZKp1+FjbhCGlyWO+YOYw X-Gm-Message-State: AOJu0Yy6jtgxShGYG+/SfpD4+Sfkr4Nwi98sx2YG/Fr7FPqg2xptxZCs Hlgqo/M6/BQzuYG/PkS1yPQUaIjLEcOJ9JySYYRTBVY7pd05vprLyEtBlFzWZdbnohRPdo/nowV z1w== 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: linux-kernel@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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791723979819102712 X-GMAIL-MSGID: 1791723979819102712 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: 205659 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp835473dyb; Fri, 23 Feb 2024 12:45:54 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX4P1h7nQjGGKZ5FxxotiXYDu0Vpfo20YqOejZDdh+4/jt5ZQPefDsa6mRiZkzrRLAev34OYh3aB0LpBVC52cvi4CtaQQ== X-Google-Smtp-Source: AGHT+IGhH3hCgRtHzWo4LDj31CwYdX2wyF92w7Qcc1OwHQmW+0VRx2M0k3PsutWaN6iLfeN9KyNe X-Received: by 2002:a1f:ec01:0:b0:4d1:4e3a:d13a with SMTP id k1-20020a1fec01000000b004d14e3ad13amr1098870vkh.12.1708721154468; Fri, 23 Feb 2024 12:45:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708721154; cv=pass; d=google.com; s=arc-20160816; b=uOMy2Ii1x9zypZjE+pDGWQY/NjVr0mVIJA3JfdCYNmI2snKSF0vXyn4TcI/y/3B7g/ niDb8FEVyp65RkNVvU5bmkBBLaU8xCMozJ/UTyzCoqwvHKgTOYJxiL/23AtLvN+WQ7Tu FrQxh6xiTgrB68Hk5TOIs6D23l7RaK+ekCMJUCpcmxphPOZhlfnOBwwVwfhYx9nykuB3 vMVx0ZHuIBUQeUEgP9zGdgl+yRyr4/Yp8o5FzGCQAzCUULRno6GUsNiaq6Bvlto0+4Ff aSwlXoadeG3dafrkLdIY0OYu45rc1iqE0w/ZWBJAfjVdqHTUSWTuAujwvfe4ByZXwRjS GMiQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :reply-to:dkim-signature; bh=VjNX97VdvJmEYHLw9j+I1sJUr3uD5daxjuOHv2NtViI=; fh=z1kV35XTK7qgx0lSaxuY8o4BsjL8ypDp7UODYZbJc98=; b=b4N2CDCcNeU+OZzaJZSPUTgONzncQbGl8WHP3fkpPhK8oAZFaxr2XUF5/VGB/OBL84 WFesLYZ13KarZs+7pb8j/Z7Jl1Co161AxKbEVSvQ7VEaYwRA/h5xvwE74Foxamkl4slN l2i1c2bCgZI8WWhFVTML1ytwgPR4nq3e0tb9IqhTAlG10eL173ZrSYxcaz5h5YYdtAdh htlXcYKnQRaB7YUFova9Zg12UisIpGWHjKHdz7uxZUkA35IUboP44dUy3ZWYJmzVWilu Ehoa7EX7JDxp0lYTx6c3HtEYu713a1ugYaPbCrDxoSkoQd34zt0BXmRKFy5rFDG+NeYl +pYA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=I7Hxh3uX; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-79129-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79129-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id gf14-20020a056214250e00b0068fe276cf6esi1146661qvb.330.2024.02.23.12.45.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 12:45:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79129-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=I7Hxh3uX; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-79129-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79129-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9F04A1C252D0 for ; Fri, 23 Feb 2024 20:45:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 01354155A4D; Fri, 23 Feb 2024 20:42:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="I7Hxh3uX" 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 BB8A314F9E6 for ; Fri, 23 Feb 2024 20:42:39 +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=1708720961; cv=none; b=I+imoX+3JU6RUvqiaMqBqQk33I8nIv/fZwagFkhQJ9LaWSnVb/Ux8yLQUPIqVPHgWSsxFHO70P45PnQuBEnG2J4eKTgJzW3VA+jza5HrkBzxXeukdRmcJFODSg8BMGrUF029jkkzrIhkTYiJ2H7a6R90j8aJL0dGP1e/ETRl5lE= 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.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 Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc6b26ce0bbso1444264276.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=HRBj6LACk4zvcTj4Ro498mC8lJ8b11cBswSB77NY9P6Q1i0R3kswIXjG5+2c9Z8ZOF m6GaRVBiuZbB8B8EZPjrfeSq2Nj1IqhpYxb3vsZgEZ8IUJj5QnEEnHEFMorpT6fX6bXz c4/Xn2Hj54ySamsxzywshFZOXv4oKclzBAZNTyUNHi6Vdsl+HPKc4Lka8gbD6pCaQgnE G/FsECNjw6uqN9UViNQzVPd2RocBqvCtIrQv/BMWCAcW4lrHCLgwmbZud4NmCfHUjyXS 3BljMOppy+PubB7gUYcTZoTP68EWCnU4xxiHyoOTCmQaGlxI02nmpBwIyMsrWjK1U5cH pT3w== X-Forwarded-Encrypted: i=1; AJvYcCU+NCCOXcdWWIbcZFeRDVdFYN1aUkfZaT6hMge+KIWmlZzH/u3MmGw71hc6SlbXBg9CTCWIBN4HpxXUSUq1KlKhVkqbUWsVT8QK0f9b X-Gm-Message-State: AOJu0YwaGEi1O3UvfN90xoCqu+qOZfDdyhkdNXrAp+sBU51nuxd1k3tS EPdn1w/UxQDb9QfqbgAcDAAc0jQ7EMXRpQWVSNwwB9mPy4QnKtVjjWSL1reLW1LHJ81sz7z9ST7 5zQ== 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: linux-kernel@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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791723992919031774 X-GMAIL-MSGID: 1791723992919031774 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: 205660 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp835605dyb; Fri, 23 Feb 2024 12:46:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXL2e2V6QrH53PSz2B4zAFKhhgo1o+MtkDi/wDyQCxk/B3wJB6gZ4RYWZOTvHcsJ+sPkK0Jg21XduKzfGMjA2A1ZGoqZw== X-Google-Smtp-Source: AGHT+IFD7ToAXixbH5FIZoOfPbFh0pZmQWaUdshto99/lYUlSiq9NAUjszG4WkNJxFd0n/cw3Bx0 X-Received: by 2002:a05:6870:40d1:b0:21f:397c:bf52 with SMTP id l17-20020a05687040d100b0021f397cbf52mr1033653oal.45.1708721169053; Fri, 23 Feb 2024 12:46:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708721169; cv=pass; d=google.com; s=arc-20160816; b=BUw6cla+5kVfHXDJbmCy1AbM5Keb2FdRcdp5X13Z8nZT6YIbmopaLnJAw3sY3givrR Jz2bTXaySNWG+JxYtKw06HhEaHDRVF+w4KTfyofHtgLrgtKZLUOgb2lpOVlqZHX+M73U ez2gLdDW9S14sNbNhbcc3U3KJmrhtK7Lq356ckLYpu1GYnth5WNxBClmHVxFvCqEK9BH Jm7czxn+ilY9qISqEOtECzdAJzfhFQqPvIcR2WpOg2P4o83F1RyPbeGP/xjLYVzaZtcB faN6sny3Vw/T4tzIG4mwTmeYqhP49YGROW+ULhP2M+S993bIh+8sPqmQtTXdSdF9v3cG TOlg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :reply-to:dkim-signature; bh=WHWPH6O3SBPytu8N+jRZuhsLbq0a353cKtc0xEMWOV0=; fh=KBLkaoguzI/mKZYNanQpLbUIVMLF+x0Z6allBgPXkZo=; b=hN8/YLMjOihAoP50hgH/ia4fsl16lGaSd9EObWcwp7+R1IRlG9+iIbOYg+w7Xm5IG5 rv2yDEmxdcVj7r/QmkFcTcZAtaJbRxCYpkV6jf92oFosvBlRh77OGTLri1/WxM880+OP jath2viYSJBQaH7iFA60TreWPGQO3b36dyXoC8dyVXYIb1izE+KoZI2E6GjIfPJic2d/ bPryM+1DyjdrYKTyfbMQZWM0XChP6+uIHLW/JwcGJTttccN75goZmMiy85aEgZzgMXsL z6kzbVPkcKXdadAlxwb7+TKsrVpA7TlsKS1/mAox5Sbk8ij7bVZTUpcIvDiu19YuB7Rx gZZg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="RLIu/5iD"; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-79130-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79130-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id o18-20020a05620a111200b00787b9fdeeeesi1112558qkk.636.2024.02.23.12.46.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 12:46:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79130-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="RLIu/5iD"; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-79130-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79130-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D2F8F1C23188 for ; Fri, 23 Feb 2024 20:46:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 295D61586C5; Fri, 23 Feb 2024 20:42:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="RLIu/5iD" 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 CF01B153513 for ; Fri, 23 Feb 2024 20:42:41 +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=1708720963; cv=none; b=mMsfKNdAyoT2hDBWbGT4CilCeOs7hEdZGG6xXBJswis7oYXBR2BgXylbfJwHk9lS1YL9YVtJb735yFlOalogK8B2kSkjkbDpvbe2zbOprf+bq2b349H1+bEzflbHv84E/JVs1g1Cuex7Rw92ieOeDNWRGeDSL3Rjn3qc+BUb8D0= 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=RLIu/5iD; 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 Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dcd94cc48a1so1230281276.3 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=1708720961; x=1709325761; 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=RLIu/5iD+zoqz+RhAk4fuiuqkqid5WFfoPhfWiE6bPZFM1UBaYyO31gLwX0lkQdAHy m9Em4E/FzUnXHoT7SgxtWq22sxR7xWhn0Nwqf+mnWbm0b/Ti3q/WzJ2BuXVgOmDjSgqQ BAHknm4jSYZrn2AaO6TBsMcql264PyXtSJ5OvxSrJFYG6MAqhBM4ZF1+espF2R/OViiI WSPhvIAiMxMUzYOjN6NwxnGCGQLqWw/mdrmL3ciHEBPno7u2o3QtfxxCAgh3b16mNw6w ///KC83uv+5e/kgfQdTHRsAvyu6OizCwY0jyAw58cADa2hH0u7QI9cKHpbUboWfbBSfY N3lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708720961; x=1709325761; 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=vqXt8jeKEdwqFSI/aFSzVFR0d2G1xtoPUP/Gy0lxPjUdy42l+XEVVDUiiB1ru+fbN8 9vuGBh91qX1jHLwfFZQ0n+3MB00aITlMry02bFO6a7cd5cmGYYJV0jadMVkXooPcNsA+ OMrB2eRAXVlFEQvCDsf8BWuimhW40dvGyVqeZU81PVSvXj9qvvaLWWg1KthRSIaLInIS VfucKCmd+44gcboFw2TJ8mRsSyzyqKbsBGKnsHmdrbKoLomuVDWK2YtO5KBEQ2mqSuM+ l4AXw3CemGlaCI7douUjC4l1DGoDXzcvHRYD8TAKLSOhIwYPYdOxuaEpg1m2N9EG4Fh4 dNLg== X-Forwarded-Encrypted: i=1; AJvYcCXQxGlrPk8w9fVtcY9j42TF44ipi1xlZwcIlPE/OI4o1be2tvC16Q7M3Pt7XAvNgjL2u3ZTN8QLZ9yEp6ZeqLfGV34NBdP1kDSLGEXh X-Gm-Message-State: AOJu0YwLa+0J9vGnNmmyv34FkonXfkHQH1161LoByM52VODyMqPdancr 0BuH2rirBKNSqDWMPMVlyS8pBI1YBl3CHcq4WH4MeW+id50j4nU9r7beAq5W8o1hK9GA1Pae189 urg== 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: linux-kernel@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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791724008498857281 X-GMAIL-MSGID: 1791724008498857281 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: 205661 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp835733dyb; Fri, 23 Feb 2024 12:46:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUWctbkwLsP59tTRTkfioLYk+eUKW4fayMEI4JKZmrVV7HI6srDOYBKPb4l+uMQpdgCuG5ZyE2agdkE2dhN+XXI96AYww== X-Google-Smtp-Source: AGHT+IGEQyG2wuyjJD0LKexQls7H98UxvVtrrtCQjfoJeipnqQqd/CaRZeq0Jr2APS+/JEFciFBZ X-Received: by 2002:a17:902:e810:b0:1db:65a3:e17f with SMTP id u16-20020a170902e81000b001db65a3e17fmr1174641plg.6.1708721190848; Fri, 23 Feb 2024 12:46:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708721190; cv=pass; d=google.com; s=arc-20160816; b=q2Ju68grl8+LdM49KNo6X+KwMG/fa/aYHqDXYmI41oDAjy7vrnjZqaTsEdIwR3eOGJ 22bf2Lg9gQU2Cddpc3v680c2TTaQeTrAQaYQD9NU0J2KadquoY04qBiyVfei7JkCJb60 neXa3gEkmLrDNr8VWSYEAfxN2OQyLOBHPAqdWSCHS1EMtL08yKgOWesaqJGPTgQpok32 glRzd5yMXT5nqxr/mazAPRi3vP41igbc1ZWQbx8DQoiqqBFBRV4PLmbdXIoFn8sNSxlP Ym6q3IHxnwxxuwN2rxdj1Ox6DqcIKCDxv7cKepowGIk2mDiMOPEbU3SB5SHlK1Up9s/Q M2RA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :reply-to:dkim-signature; bh=5BA83Ml2Mr+6P5rMV7bzjFJqA1AMsjlfbBOavKz4yto=; fh=Pa+lFPCAPmb1KrfR47qC2VuK8OOiB7SUc2KTNBMYxKE=; b=u49gTGkV8xk/6itWwJX81sxL+CBNjgIyIV1eOta0V+n2BFXAYfefzwip5DfvslZVy3 qfTCtEws8WQiZG5ruX16IYhiLFa98tYuovs+1c5bkMU/jx8IDB5GfWWjDcD/i04tav8w wrrUPTa5gLQPtFRzdO6sMgY3oTGoOk0+0sbylTgvM8Wywv6nYVfHZrN9TKQyuOCerTIu u28EEHTKH6uJPOMaOI0PKMwqfxwFXjHHqHTOPOCZ9iF6fafnATEGakyG30xypF/3sdHP qi6vSLzbmR0Hj2lwYQ+HquLRbzIC3gfmTYjT0RwOQYfJfPHJBO/KiRryyxIFiSLdac3Z WuHg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="mfei++X/"; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-79131-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79131-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id g1-20020a170902740100b001dc41a37400si4496553pll.343.2024.02.23.12.46.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 12:46:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79131-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="mfei++X/"; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-79131-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79131-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6F924289E88 for ; Fri, 23 Feb 2024 20:46:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8FE6C1586E8; Fri, 23 Feb 2024 20:42:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="mfei++X/" 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 879CA1552FD 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=1708720964; cv=none; b=Bzxg59Z7jGLlIE8cbMeot6T13pJbGrcv5A3JYW+3Kh48qxQm8T9/BbXPUaexK94EANONHGqrwzpBtCfLMnQHmuJ+xBAmEAMqlTg3x14wMfD49UiVbLqPuHQfi1FVRxkp8lmdiRisS4QT4+EXVueoPDsUu4dAhD1DIdruInkOKQE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708720964; c=relaxed/simple; bh=I0QVUNXtcgHX8n+zXfP8ri6kLK8vFj5GkBmrqx6hkTs=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=tfhJ4godpeqeXnpBxtutn8ti++eAg+NIAaIibTQxxdi0a+MGVmbnTkUJZiS/xGO8LKHxui8dM3eLXefEtWqAh5lyLvIOc72OAeHIk+lQgT2l5IfmDKkrGMFd6H88tMPbDLdntGSGZqRsA2/p5FLBWYZKtIGVrOsNrxV1ySz6YJw= 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 Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-6e356790f94so893987b3a.1 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=gRduc1s+HJzLCzRXsiaVNPDiXWjwvs3g9Fkyf3zqfWTZyzguSvgvJsFSOv84s/dReT rS19cbFK7Ass8WuxyxlBeu0MGUQg+UgM6Dr5h+qRNukQbZYW2f8LJGrKkRVYjwzm/VBh laPEXizEXDUnpkiZOCYMuLyc8JYZRPMoePTFCAmFmjWnDaXq8YfoMnXeAG81lopy1OuT 3iA0jFKcvOkztxEGLj4sTKII6qFvRWZCYWW+prGXFmiPKq3mNbdzuNPxeju6f21LhqC5 zsMrTzkfuyW6Y9xrpTxDXew8ekZnjp3901KCFlS/8GG4plIpzXIJir/AwjUhS2XWu9y4 HXWA== X-Forwarded-Encrypted: i=1; AJvYcCVVwt6O8eEDUMgjQQgQDuKt2mN7rf72rt0RRvWpfyyVh7CFEGi10SwCFY063UTOkOKANXEh7C1ih4UKSJKyHOoECeo2KVo37V+rAvx2 X-Gm-Message-State: AOJu0YxlONsJYZ2J4H0Kbo+vd1u2yfNfgg9jxLLP+MIrk85DQhsn6zID s80D9lD1VhGa9QEltylxzXeMkq4UX0LHE1Ku3jdnZ9/bQZuBnQ7ry8nD8h0U3Uxe9u/iMBgktR7 O9A== 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: linux-kernel@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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791724031247997350 X-GMAIL-MSGID: 1791724031247997350 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: 205662 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp835748dyb; Fri, 23 Feb 2024 12:46:33 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUx6xqa8pK/voglg2pY1fnAHKcx3x0sKKFHjlbz+HkiX+D09jYfn1vpCDBtU059/zDHjebKoQz5WHlTBKvlx3/up5fQ9w== X-Google-Smtp-Source: AGHT+IEhXeH+tLYoCfeo12Yne6ErBQwhDZ/GXp4pcWhTRvJdxq+bEFmpEProy3wQI9HdnD3GOOV8 X-Received: by 2002:a05:620a:1248:b0:787:b595:8af2 with SMTP id a8-20020a05620a124800b00787b5958af2mr942058qkl.73.1708721192982; Fri, 23 Feb 2024 12:46:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708721192; cv=pass; d=google.com; s=arc-20160816; b=WM4+auTWI5MpIybDTyZIG/1HLf4QBl128j2kQiMDz0h3JkixTD4jgdOnDkoM2KvzA+ +XWhgXZGFdovurvC2fFWOyiMFbnZS7aORCWdAgV8X0bCkpYjiKoTbHv4zucJ3S2D1/NY gKXKHTmy1gABnue8+3tgEcFXmH3WqU0UoUbMQjZ5IcRjwcRiudxwZtZE6kTiHNAJCc85 05orWpozy5tABSQK8hziGgR4QAITBUcQb5o4yNNdR+7LIhBp6HGBLrMjwYJ2Z0g/yx66 9QclzCtlK+r3Xxv3dhgFubfQoDfIG+bOuKvqfZo3TnhVqS0TwskjvFdj+6atDOA31e0V Vt6g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :reply-to:dkim-signature; bh=fjPJ3Hja7aXkfyUdgxA5xTLuvAk9amyqKFMcOEhsGqM=; fh=GQw9bD8DgeW7uBUryaq0WKLuaHq6gqJJRTolK8AHjII=; b=jyLT262gJ01lkTMiWtsas+50Qwwkoy0wxhZ8mC0ZPUtN6WHXwtr7ImvOSB9SjJghtV guQ9LchEZI18am2eJwBHujlkWR4L0jV7FGyRTMq2tSBqdOuUp0r3j2D28T5rJqDOeuXg MKGXcl+V/71zB1h5JLlPNEcWkeTtq9EV4MO5D+b5RobA2JRoMdixMX2wDNQy4hVBg73u NzbUk1yXcu+b23DBwC2bU2oJ1d84d/sJh9lRabv2bfx1yAv2e+F7S+aId/Nb3tpNU9m7 T0SH1tAJutiZFXOuncrUqdyvtfJ5b6G3QKf6vhfE4b1jSDixR03ASX/xnJi6wfCTS9M8 L2yg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=CmekOdEZ; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-79132-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79132-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id l21-20020a05620a28d500b00787b434d4cesi2034240qkp.639.2024.02.23.12.46.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 12:46:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79132-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=CmekOdEZ; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-79132-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79132-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B23681C22031 for ; Fri, 23 Feb 2024 20:46:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C5A84158D83; Fri, 23 Feb 2024 20:42:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="CmekOdEZ" 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 9E410157E97 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 Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6085e433063so13382887b3.1 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=ua0HCKSj6lhgH+iFDb1YEWjXMoAYXlislouhePCwvjyEbbtWYspnF7I1QTct+WOkP2 7qyZn6u6Pe7Zlf77VG/8LvLs3CjmApL0BXbUaUkS7ahobLuqV3QXGPlenR60L4gOVIoQ GmCpteaCopbP7cFBfMKsNRtGiVb7qvxVEnPvvP81144HOpITnxLoEO7Y3HVUOnRpyzGz +z2kKIFFEU+iIxzxutEm3Q0iTurWPDFI8AN+TWpYVd1hvTXrCSbWavBZQUte7hXOPZIq EenyhoAiihVJZhRalH+5vWC9gkUWrrWvYATnosUy2qPjBfL0YYtLLDGdYyCEBzIdGgui pihQ== X-Forwarded-Encrypted: i=1; AJvYcCUweSXGwsuVWF+yUSUF/2cGxLMjhVepb8zeYyFjw1LmtBIddO9YnsEs98RvMafgUXUp411K8J+IjR3tyMlvNxx6sv7mdlJ0pk0S3DCt X-Gm-Message-State: AOJu0Yx9vbaePu46LWvSznIAlvZ+Z3xdLarNRSDTYpzoVz857fqM+Yij bdZUkgJZHLf+NxWqqtLhBV2tlR9l6o4sd+WY4EkgRDAqYHUWjPKOgFUvs7EUVrcljhLJ439hGFM n1w== 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: linux-kernel@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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791724033674320614 X-GMAIL-MSGID: 1791724033674320614 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: 205663 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp835924dyb; Fri, 23 Feb 2024 12:47:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVP8wizPyNRHOsQQqpIqTYwNE0qpPJTVVDegXaFwK1CPMbP4jTraYvmxWHUvKnLtSw7wwRpY5Q5hoSMwLtgDvvyNqiusQ== X-Google-Smtp-Source: AGHT+IE8hUUyyZe2ot3bds28juQHsOykyPgTx4I2RRXNqXBtZiPqkly7upo+T4aOUfedMx1kX9fP X-Received: by 2002:a05:6a00:cd4:b0:6e4:74d9:6901 with SMTP id b20-20020a056a000cd400b006e474d96901mr1271770pfv.12.1708721221256; Fri, 23 Feb 2024 12:47:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708721221; cv=pass; d=google.com; s=arc-20160816; b=0QRYFRDeLi6Is+kVGL0ERDaMLsyA+8jEzs5JyXInriKkLgF06zxjBm6ynxUkYuk9r2 i0Dbj5z4XpCp+uGJAJkvqpE9gtxS52hSkmbmXBCugUhUzyVZ5ab/Z9SGH3VVIt4AbqGJ ErG6NfKe1h6pm3RFHCGhWd6REXB94lTURcHINJmDkhZ9XY99arKLjXYgNE2zQT797j0H Uf3pNoBR3Yf57nc+XLt5rEbz/u36Bvn4AyzRf+K3DarmcTF0aqJaKKr2t170VWVmqsjL Zb/7x7CTeZfgrFJ70eF6BX3J3uii3bk1ZGeGF+H297SMS0+Wtc194suK5cEBl1w7DXq4 m7XQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :reply-to:dkim-signature; bh=eMiAiix9phUQ/h1sG+JlRQvWAIP+ZL2r3XfvgJSywGA=; fh=qqc8aLcx5CqhMyEgHoe+CfqCfiOv1gNJdW4ZA5NqrWU=; b=THPcYCW/vyGmnh+xkGZVvVpYqr68fRMNn3P+lIsFkB0JBtAwkJ8yzrnfQNMsFwNShJ ReG+gsPUovcuV1rd2EmWzCSJRyWkhK2K+kEmZdIw4Sho0dN/NrKuy227O/t09JmXmAwo i207z6cHfw6wSuf7yfSXA1gJ2HQYEL676OLLBsTcqoP17tA+LoWlUupLhsh5b1bMpwcC TlNR9ub68wrdkme6iCMMYwsvsyh4NW1zo6+5mHQzZgn3nK6fKm3R4vL6jNSiua/AoqfV zgbjeJZXBfxBL2YX+lRHqg4tBD8tpPG5cJwozsnzWMgMZ+J5B/5SlLLZ1aWjnYvvQ9Ap 2bhw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=t8oFKth8; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-79133-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79133-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id b11-20020a6567cb000000b005cdf9923679si12648138pgs.727.2024.02.23.12.47.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 12:47:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79133-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=t8oFKth8; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-79133-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79133-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 42EAC285764 for ; Fri, 23 Feb 2024 20:46:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E97015958A; Fri, 23 Feb 2024 20:42:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="t8oFKth8" Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.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 8AC4D1493BC for ; Fri, 23 Feb 2024 20:42:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708720970; cv=none; b=IRG0lPultgyol/frkQCiYcK+ZNcobAEVY3WOMns/w1GPTMJQTaKpty/NaNs357/H1FcpWZ5uu1ZV1njGXhT+qwVh6WH80pVs+dMlwC/vSJsssli0DpmYU+MGFeEIaGMNVPPxo08Jqqd7CmaqLImtx6GNw6CGD1JSY+Y6MLtpxrM= 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.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 Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-5dc91de351fso925413a12.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=TSgQkth+bYPOIQARYEuRGDQgdnZCEmXTKemIGfPZQ5u6ZFvp/oJJwRsd1FoHx7fWVo jSbLy2X+MaISl9xkoDLcdr+4KYVSGeP7anSv0SUsBmNdZJaqa2Yh1EiD3WmIuRmsM8kg T0HWqwvKYLhzvIRLc9Nq5YdomeJ41infQ26n+yTGtx0lu7y8xFadtlzCODnLsKiPl2mu J6ROzW3dJF1amHgzbp0l8+Dy1oWaAOvL60O/XAymdOuK3ptBSKKUvcvVFBBNv6+Z/AVy 6qpaohMNWrTPcVa4CfHZobIW7vAac5JqPUZNcs8R4GIy4zsnWjyYMArL77+zoOWQZG5O rqoQ== X-Forwarded-Encrypted: i=1; AJvYcCW/xGZ29Uq6AIPVnwPKSiT7POZdQlOyrcdUCsoMG2FRKNKW3QvZA9psRmGxqaMUCcylMD/l1TviJ9EpZ7Ya/SI5AtgK5EGlMxG0fv6P X-Gm-Message-State: AOJu0YyxIeVqUpmEmjBJe9VDjMKCNScjGDW1DTrOzKPHRGqeH8O/ql73 nwkPIzK/ZvJBz2SPKZFf57uS1RCTdcihlEc8/88dFLGj9YsOB567jwEVnFzooC+apHrOzdVkdGO KNw== 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: linux-kernel@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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791724063193513717 X-GMAIL-MSGID: 1791724063193513717 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: 205664 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp835977dyb; Fri, 23 Feb 2024 12:47:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW08QyTPQoqR65BeyrXVzgPPO/mpU90mVT/xJfY2R16bK6X9yzrtsoRY/XQ0fljsHDJFvx+qDyVBFDUeRsC4SF+jWJZ3w== X-Google-Smtp-Source: AGHT+IGlXx1k2rDO77/A/Glnz7MaUbGZb4oh8a10GRjDozaENAOyM3Fa0oORTw+J87oPXxExRWir X-Received: by 2002:a17:906:168d:b0:a3d:bb68:be30 with SMTP id s13-20020a170906168d00b00a3dbb68be30mr701314ejd.6.1708721231302; Fri, 23 Feb 2024 12:47:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708721231; cv=pass; d=google.com; s=arc-20160816; b=H/gfHajN47y5aTkFv8pIWeXy2eh+/oamoAIYlL2SXb3lRa0dJbSzHZOWAhN6zd9AXb sUjGBdLpMBu0oRrIRnOJVBwTHs04adzuLYKqKa0YUFmtbLsI9YISpnCfU2Wc2dcpPqwH NSioPhWXBylKnTQqM7ainFKK2vIbrc5biZIEjkNX/hb3emiCRB0FElX59J0G31b1WSOS a6e0FYbJyiRp5k0ULycIGHpPm8AQofigRxXVaSzKHagdfUU/TJe17xF19U8eM2bPwG09 9GEVcwD7j88PbYldMp+Zpo8YCxNRaWjsl//pOOLT4cQlYg1mlBgHZpYNpwNSnRWy28Rt dDlw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :reply-to:dkim-signature; bh=FfzNCmRZ0S/1zY2q7LR3gyLGd166iHY+ytisyKJMCXE=; fh=RzqJtP8H/dXjhC3yV4/7BFS6Ab9jCksIMQ8xPM+aPPw=; b=Se4wLKp4VHZIpa3JTgWnPjN9+ToSz31avyqdeN6d+u5u65wrptBC38rwsZ1oA5mZmA KZ6ez+dscPV4+zsSJ5o8jpviMs5FnQSvIJw2RrRPz6v/dbsNxJVhOCA44czwbLN9XZWV L/d8Wy1d9pQsuWMxpbX5zyhCt9cHoRdDnLMJAfGLcT4wpfds/z7AaR48pxl4GXNj9Jau 6gbmaXjMNUF/GtHwCVWzGjo8StZTYOIt7isDbGZ5H+041jZYngNcpzBvStUI5pkjWI6q 8qyl1N4EIyiTkA3t29iNK0YpP7To1/rZy0hJj7RV295S/uTwY54m45Te83bL6cqNpwa7 dTdw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=bpT+2oIB; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-79134-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79134-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ho12-20020a1709070e8c00b00a3f5732bdc1si2392994ejc.376.2024.02.23.12.47.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 12:47:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79134-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=bpT+2oIB; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-79134-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79134-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E6F5A1F227E7 for ; Fri, 23 Feb 2024 20:47:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 33B9314C5AA; Fri, 23 Feb 2024 20:42:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="bpT+2oIB" 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 E348A158D8D for ; Fri, 23 Feb 2024 20:42:50 +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=1708720972; cv=none; b=Yl1L/nD8KRQbEyPrittucUd+Tw60rqrBvbGPibet3bpwlv6/roolQfrLoawZSnE/awgaski6O7qneA9G4LfzcXySa9t5wnV4pGihow0VwCKe3/qyt2F3gSdV3bdM4urqVfytKl/kUdCr+GCxh/jKZfLtNHyJJNogeovdkaF3BO0= 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.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 Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-608ad239f8fso22867787b3.0 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=atq7cv6O6MZJHpLkhDXnegsgiGByQt0OH5KRO70HfkWMiovyDvrZ3vQRhu68CjBgKj IIAGqJ1Qhx55EjA3JusQRFwQU5w6Gp5Kbh1HFkzAEJi7pKYuEBqPAO6EOF9l7/FaToHm S/2SI4OGwvbZkwKSBLtCs9Oh/KETcNpfphdo4Faqi0L4AfEuSfJ153Kh1/qWagg0/yXX zehmMkFgsPtGRhs2MNE/W1z/EUrJWKa6Ow6r1TSOAZZazhBETxSYtmQ+W6DWNPGHinDI MHmC3PyRwzM2RNEvvPrGWGQGnVS632yiBLcXWnG05KYS589/bJVP3eUfhNSJ9qffYRIE 0n8g== X-Forwarded-Encrypted: i=1; AJvYcCWT7Z+aPcEPtvCEvzUNI2ePkCqxXhLm56b4IcqtYzeAhjVvV6rb6XYy/U2GhJZ0O8pWT11gWrA++eXocovFgytSOawVPvj2BPs+kOdl X-Gm-Message-State: AOJu0YyKNCNCBEywvL0JinIKQp6kjxXukN0Tejv1MHVYpbSjSZtx2vdq JsGAYHfc3RTFPOdCpB3TIMGtXZ9FhxqHTwAQQQmhgRM6Be68FsujRvr0YIyfP5nQOZu7qrsTWst SQQ== 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: linux-kernel@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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791724073468291819 X-GMAIL-MSGID: 1791724073468291819 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: 205665 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp836023dyb; Fri, 23 Feb 2024 12:47:21 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV5fNpYYs++SM+LKxcj0+T9dxFhEADTJ93OK2EgKKGy7tysi2hHevVAB1zf1iy4ar/5fse8SsZ08VKJIYrHQQmidAMJ6A== X-Google-Smtp-Source: AGHT+IHhCtLJOowHKnHxvExNIhC8tLCs/z6Spak6QhOHadGaeEeL0EtDbJ7fDzVYNrVeLvI1NUX/ X-Received: by 2002:a05:6870:8e14:b0:21e:5eac:a695 with SMTP id lw20-20020a0568708e1400b0021e5eaca695mr1071062oab.14.1708721241386; Fri, 23 Feb 2024 12:47:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708721241; cv=pass; d=google.com; s=arc-20160816; b=KpRv56ACNJlJzDgIiChO8HmXpfZFfZg24oCfTKSui9kHOEL3tpM9zz0aW9XiDeJSFp slQByRLgbckksc4UdWeq9x6h78mGZnRudkyJ4c634MUoyc4Wak33OmyjOzj30V+XVGIy iQA+CqRYy8KxW8kLcpC/3mPmTl0KalaTECiIdensPApQyfAlS/+GEZb+jiiInUf8JuO3 TfHH7TRajKXbu1UzPt6f1to2pk3rFIf5K68zJs9tfrXSCHRqHmlpNQ59rL7Sla9I4IL0 +jIFFms4O4GX0VNvFTdGvVp2uOEa1Xjut1wVcQ/YS4eJ747x2JuFTxV4pti85EOpofWb mZIg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :reply-to:dkim-signature; bh=vufYXRT9nLolRxc38rSYg/MmpkjAZM5KmaatkmS8vks=; fh=qNZq4eRA852oN9ugCnPbtwM6GzdZVh4sat8J//haGd4=; b=eK6H+zqrXcU0Iks4eE/wBn/Dbh+NOCnruxk9QuYmqQzcXRtaNN2LPomlgmNzXptZFx p5Ae0r4rTZ9Yaup9RZMwCZMxX1BDB2WBX1V0pJhs1EQldAZPQWgbieZlhtEZIEcFQZv7 diqsbjF9EZEeeH8Jnq9ew7GGCFpnwcx/mjYJEQZUNDbl8mWFSgzGrVSYorYGoBjtQL/D mrMPjgTsQkeUl2otFPCtJ/YwKjfOCmMvQ1y9w5jorXnMi3g8nayTc4dbyAcYAXSOdv5g RvZIBvqoTAsvsnU6wf8mD/W2AxsIWvC6OgoHOc/VzbPQi56ib6gcha0o+KZwwBS282iI 3OmA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=4nQsW9sa; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-79135-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79135-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id wj14-20020a05620a574e00b00787b7df206esi1375121qkn.201.2024.02.23.12.47.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 12:47:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79135-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=4nQsW9sa; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-79135-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79135-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 29C2E1C242E9 for ; Fri, 23 Feb 2024 20:47:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 12B3E14CAA0; Fri, 23 Feb 2024 20:42:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="4nQsW9sa" 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 E4346159580 for ; Fri, 23 Feb 2024 20:42:52 +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=1708720974; cv=none; b=NHExLM+o4F+RcL81NUL1at+AFnFkV6ExiDYYRf5plk1FPwXgO1sg4s6Q6fbREHxNvyPZN/gGdPRuhBXgYvg3rKJP4tjjpmm4PetJ9e9IiBbXiCOxG4tPcuVlisf0EHWWIM7YXabAO9L/qRNfWZRxbl7ec2ZE6uGBkmYYy1665E8= 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.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 Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-608a1a2723cso19512977b3.0 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=F/cYEYuM/V7WPZxFBVp0D7wxQ5PurmyveKU3hYCEo5K1A0yLjJqyKWzq0JYUoxWPhJ a4pSeMYSCgDhBvymxIBOAM1S95Dax04o4d48KJOEzWZmCsSBu/bDQMtn/3zdXaC8pfsU zyEo0zH2Vpl7JOurpC66SMtVBwR21Y2YolW7uV+E/b4EL+jQQ5fW+mjyBvvYNPrx4AUt KMoZhbojS3scleuUpC7d2Q+lEeFBOwYWbf/7F+UI4SlPZ6mU9PSCBhmVOARQrXjNv5do gLU5rMia2bQLD4zFunxhfly0WRhw+zL/ZmBEVVWJhp4Q0xP+JCOnrDNP3atnCZJ04t/R Ji/Q== X-Forwarded-Encrypted: i=1; AJvYcCUdjwbXX3OTOQurOR6I6P2lsE0ayTNrFkxTK5msvMubftkXMls77v/kVq0ceZPRNc7BGNEreH0+VrllKFbAqevUNXvAwkvndTMj/zMt X-Gm-Message-State: AOJu0YwCurU0dx85ATifLq6U83fTQdG2OaF2mNDljh2I14D8FsKczVDP 1CNqcRm9uUf/DkXZ7nvcZzslL72WIFXf5j6kSj0OS4Wbg+EmKGcPwRHNblnYZ63fgMJiDgTSu1L tNw== 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: linux-kernel@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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791724084582164951 X-GMAIL-MSGID: 1791724084582164951 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 \