Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp804167lqg; Sat, 2 Mar 2024 02:28:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWBcE5kz8VYW9fTABJqUFrmH3HAirtdpO9G6a5F7pVav4wxojRRffMZNQ8qjU3truh0nmTZO/Ejmeu0br9UxoyTSUqOf/CEo63/wFadog== X-Google-Smtp-Source: AGHT+IHPTXajWCUjmBJQ7C2QJefZxPFR/O/N/fFUioAKHvNCJrJNkyw21FYhl3ziIm+GLR5ueZBl X-Received: by 2002:a67:fb16:0:b0:472:6061:45f1 with SMTP id d22-20020a67fb16000000b00472606145f1mr3852989vsr.13.1709375310745; Sat, 02 Mar 2024 02:28:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709375310; cv=pass; d=google.com; s=arc-20160816; b=uNfJWoGwGPSLInovB2HCf8xBykmjKR8CDQeb8r1INzl6567W2JNEM+RIYgvmyr930B y+o9PuV15SBn1SaOn3mYtnBTgJDCXumM5OElU+W0vKPxlft5t93jAuGiFlNW/EG8r2jI q97tBXQ24Y8mLXGjxY6KukJau27k5qp84cmzqaTtiFlyt7yf+pSA2BYjq+esiBCttlTn NMCrEUH2qfWcNKdnOxIENKLvuHYFjJ9OmFRKI0a0bEj6IGKIMaDYtgOYDOnGkqIu6En7 OPwxJciUIztd08jVBOTq6w99/ufWBHK90nBv2lIpuS22I5tjI+8yXMiSWaRZF2VllyDm 3NqQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:references:in-reply-to:subject:cc:to:from:message-id :date:dkim-signature; bh=XNYw0swGw+VXYQ+JkPaX427Meqfy1T3LFl26yU6QfZA=; fh=ALj3L8ac0pOVnT248tQqchdouzHe2ZXBFQpMuMne9RE=; b=oLxeZMVjMFhuQnwccoeFAoMHIflN681B3n3OXzj0Km0nch+osIRLUgi4JL+77vv/7X entqV8/Vr+Ndv4i0Psah9dz7Oi2LIAcTrU07aNqlRXLaZUdsN5NAApEV+YKcLRq47/Y0 dgUReJZbcS7yRfZLXkjyG7eZpTTh2u2cbjjZb3+R42a+eaEGXQeqSDlXGOTVHSoN9yoF tRWNO6r/ZJ87lTeEbif3qVvkUMfBNAhMdLX6s7ODFn7gBiQE1kr5V8eKu7Dob7Y9X2eU ryj9LQSqEUwDVmyfgDn+CXZfL97rgcLE05kRNpKoH3jsRM96kqjtDxzETUu6t5WZS2F8 iM1g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RQGCCzLt; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-89413-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89413-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u37-20020a05622a19a500b0042eb3ecb48fsi5708563qtc.443.2024.03.02.02.28.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Mar 2024 02:28:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89413-linux.lists.archive=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=@kernel.org header.s=k20201202 header.b=RQGCCzLt; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-89413-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89413-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 75A821C20DE0 for ; Sat, 2 Mar 2024 10:28:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3953816439; Sat, 2 Mar 2024 10:28:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RQGCCzLt" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A2D714F7A; Sat, 2 Mar 2024 10:28:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709375304; cv=none; b=CZ59KYncEF2T9Xaujkkx/zgjjVLENvJ7QYIYdJLvHS+iXbw9I/C77eJcO37yxBxsBiAm340MfK2Enr5P37Z32MotFC9jq7Asl6HF5vBxO/HzwRO/HG/Nvvs/Xn3vbbxb0YSLe3mM7T5h1bWtZ8Pl6qkEysHsQx1MdrUO+rl5DUU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709375304; c=relaxed/simple; bh=kRNWOYU8T+ZFbq5usH3n+8N5CzZwfz8CMOtijDS/0aw=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=QsC5IrBjy3hnyXKtb89bdTYbYQchQZg8qh/A5vjYuoubzolflY9WrSuMNWVFB6EmsJcQnnjjvR+tTYAhKZRvXctyA2BBC99YllQjSSb9dP8DGPm8fiQ6XRRBTSOoqZOT8QOQPH/1qP0sUqijxdhfyrmVIE5xidHkUAHy072f8dA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RQGCCzLt; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2BFEC433C7; Sat, 2 Mar 2024 10:28:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709375303; bh=kRNWOYU8T+ZFbq5usH3n+8N5CzZwfz8CMOtijDS/0aw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=RQGCCzLttX84RHusWIlDSxVWEgvr+tWVds3hVN5QO819Y3k7qGK8p+drrUpCsnUjf N1k4fPme84VrtbEbXB9yUsqHkpgbIrnqexDOYECwp8bZhPzL5DGMwHW49/gfMdYaqs iZOuXFsOVI5C7tJXBBr/V+JHDapJh3qXnvU5emEypvZNTqMcvByXGEazzCPuifcX0L /TpQHXN/FNQvq33b01cprDZDZs6k7VrOpT9PVc6iqNPvI+RQFkV/PmKAqoupkXQft5 oSDNHfK/zXMOTKzdJh42OA0pCSRkV76Cv5LRDfp0ZO9zqsjfvTbQ3Y9XRSLD4tK5/I ByXR9x9CKs4aQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rgMbN-008l2V-C6; Sat, 02 Mar 2024 10:28:21 +0000 Date: Sat, 02 Mar 2024 10:28:18 +0000 Message-ID: <86zfvh0vy5.wl-maz@kernel.org> From: Marc Zyngier To: Mark Brown Cc: Oliver Upton , James Morse , Suzuki K Poulose , Catalin Marinas , Will Deacon , Joey Gouly , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] KVM: arm64: Only save S1PIE registers when dirty In-Reply-To: <562f5e62-c26c-41d9-9ab9-aac02c91c7ae@sirena.org.uk> References: <20240301-kvm-arm64-defer-regs-v1-1-401e3de92e97@kernel.org> <562f5e62-c26c-41d9-9ab9-aac02c91c7ae@sirena.org.uk> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: broonie@kernel.org, oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org, joey.gouly@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Fri, 01 Mar 2024 21:13:26 +0000, Mark Brown wrote: > > [1 ] > On Fri, Mar 01, 2024 at 07:32:28PM +0000, Oliver Upton wrote: > > On Fri, Mar 01, 2024 at 06:05:53PM +0000, Mark Brown wrote: > > > > I don't have a good sense if this is a good idea or not, or if this is a > > > desirable implementation of the concept - the patch is based on some > > > concerns about the cost of the system register context switching. We > > > should be able to do something similar for some of the other registers. > > > Is there any data beyond a microbenchmark to suggest save elision > > benefits the VM at all? The idea of baking the trap configuration based > > on what KVM _thinks_ the guest will do isn't particularly exciting. This > > doesn't seem to be a one-size-fits-all solution. > > No, and as I said above I'm really not confident about this. There's no > hardware with these registers yet as far as I know so I don't know how > meaningful any benchmark would be anyway, and as you suggest even with a > benchmark a new guest could always come along and blow performance up > with a change in access patterns. > > > The overheads of guest exits are extremely configuration dependent, and > > on VHE the save/restore of EL1 state happens at vcpu_load() / vcpu_put() > > rather than every exit. There isn't a whole lot KVM can do to lessen the > > blow of sharing EL1 in the nVHE configuration. > > > Looking a bit further out, the cost of traps will be dramatically higher > > when running as a guest hypervisor, so we'd want to avoid them if > > possible... > > Indeed, but OTOH I got some complaints about adding more system register Complains from whom? I can't see anything in my inbox, so it my conclusion that these "issues" are not serious enough to be publicly mentioned. > switching in __sysreg_save_el1_state() for one of my other serieses that > specifically mentioned nested virt and there don't seem to be a huge > range of other options for reducing what we're doing with context > switching without using traps to figure out what's in use, especially in > the nVHE case. I figured I'd send the patch so the idea could be > considered. nVHE has a cost. If someone finds it too slow, they can use VHE. If they rely on nVHE for isolation, then they know exactly what they are paying for. They can also avoid exposing the feature to the guest, which will remove *any* save/restore. because *that* is the right thing to do if you want to minimise the impact of additional features. If anything, I'm actually minded to remove existing instances of this stupid trapping, such as PAuth, which is entirely pointless. Sysreg access should essentially be free. 90% of it is done out of context, and requires no synchronisation. If someone has HW that is so badly affected by something that should have the same cost as a NOP, they can borrow a hammer from my toolbox and put this HW out of its misery. The only case where this sort of trap can be beneficial is when the cost of the trap (over 60 64bit registers being saved/restored -- that's host and guest's GPRs) is small compared to the cost of the context switch of the trapped state. This may make sense for FP, SVE and the like. Doesn't make much sense for anything else. M. -- Without deviation from the norm, progress is not possible.