Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1105300rdb; Fri, 2 Feb 2024 14:01:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IGJuQIiGpPuBmeu/jaVli6p7KGWFoxbCrxPXABBPDKbbwg4xnEbzmdTzmQPWWMQfbXiU/cp X-Received: by 2002:ac8:57d6:0:b0:42a:b7d2:5673 with SMTP id w22-20020ac857d6000000b0042ab7d25673mr819959qta.6.1706911266574; Fri, 02 Feb 2024 14:01:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706911266; cv=pass; d=google.com; s=arc-20160816; b=lQgINQubyp/nvjKqo14AzkxflUWzhLoBc+ADlEkW35cK8X5PKhCvavGAkTDomTv7nD tG+pPzVky+cuDUOtxUJ18aSJkjb7LVnZrCKwurFZ6g3vnFVkqoST/vjlbmev/RisRLtj L09vHGFP9LyELSUTQVRFfnKOFmlao6eb3rQ/nYqFOFFKGOA36MLyKCsdNJDFspR3zqUq 79C87GLeAg04/NokrO3AebY6gy9tuvVHoZZNQ3qxKgjvq3AXeD3pvOVrWKwQq0bM9PNn i0inmMix5sOTCIT2eWORKmGUnXFOhMUwDXr639SqkGoVLouxVbpxfB4AVK+0qFLHS5Hc 1Vkw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:dkim-signature:date; bh=+zpF3hh3I48blUHSumiD5JMU6whQC2+CI14iV5XbGAM=; fh=mePIwmNy+a/0fjLulP0tMIy9aoitC+EdJh9iuqrWYYQ=; b=ZHDGPIoFfEb79ngSQnD405bZpsEe5xc08CLyT2qB6SKmtufPKCc+PoTweqLgijEfX/ y1Um6gXppV2WbmNrf/CWduLmufYA8v4pkMpJmBche13Q8QrNQaN4dLegxfAG1BAUTl9B zzURkxjG7jwsXaQCkaXDWlYbceu0tS3GWkRfyjgMknWD8kuBhJbdTgNCGdyWnRZIocFJ bA9j73qENyxj29sQS3fLJ2OhMokbLKUmlJJGvNJYBH5RZLHFTEOgtGl1aErlFJOv81d+ 9OavXy0WwwX97cRIxKB0kZpJmR0ra/WNKHHhulWMexwgHbzOeqovmdasgRSgMKSFof3u C6Kw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=JJ7tWXl+; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-50630-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50630-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev X-Forwarded-Encrypted: i=1; AJvYcCV0gzkxs1j/lOh+jGwxcMLUpuTqsLy+ap9RJbQN6Mbl8/Q5UVSf+xLpOYu/izg3E3wihs6V8n2hZ0S9C2HukFP3duDft+yA3aFSvRTozg== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id v6-20020a05622a014600b0042bf69979f1si2917566qtw.419.2024.02.02.14.01.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 14:01:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50630-linux.lists.archive=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=@linux.dev header.s=key1 header.b=JJ7tWXl+; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-50630-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50630-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 53A9D1C21B42 for ; Fri, 2 Feb 2024 22:01:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7308083A19; Fri, 2 Feb 2024 22:00:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="JJ7tWXl+" Received: from out-171.mta1.migadu.com (out-171.mta1.migadu.com [95.215.58.171]) (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 D4DF383A06 for ; Fri, 2 Feb 2024 22:00:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706911253; cv=none; b=X8awD8e/kfp+2nvpYCpBXCgmOQmfsO766xnma9l+kHBj0yUyFI+oBj2dcz8fvsxWI2psPrXxIr5XSCWp//f+idaJF1nY6OKtYgP3ZnMCLgDYgyVvOXF3p6Tyjt7g2TedjqTYQrA3QvhEsy0OKmLPGuuDKvxsTGpqkrwEerso5pk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706911253; c=relaxed/simple; bh=N7TSsTyTTpBhvIoyIV72Wm9XXJoUcSnN+bUHy/4yQS8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Tgn6ArNnjJx8/vGoqzJwVaPMHRW+YA8Sx0XwSFZFaaOy1/ojtgClEDQIo6RjNuyYBRXUZUuCczLI47wuyNymvGn1qwqf/ZKmZZnyrbNNjEy4T8JBD7L/JU3acYHBdcJ1N17bMPs2ZzykQonkoa/7aooif4NPIyRlguBwyEhTnLQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=JJ7tWXl+; arc=none smtp.client-ip=95.215.58.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Date: Fri, 2 Feb 2024 22:00:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1706911249; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+zpF3hh3I48blUHSumiD5JMU6whQC2+CI14iV5XbGAM=; b=JJ7tWXl+TCmh5A/3ptirM/eUN3eqQtT2AfiAKO5tZ1pUy6x3ZKvSR0taZR4bYN+3pcFneK pOIJcFwAh7whf8AOwC8P1Kh1b/7HVlktnIpRJU9HbzQoZkyavGQnze9jNn3hSkT/H2Drpf /H1OGLttkJYqaBRw+DDwl+sTpNaVhxs= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: James Clark Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, broonie@kernel.org, maz@kernel.org, suzuki.poulose@arm.com, acme@kernel.org, James Morse , Zenghui Yu , Catalin Marinas , Will Deacon , Mike Leach , Leo Yan , Alexander Shishkin , Anshuman Khandual , Rob Herring , Miguel Luis , Jintack Lim , Ard Biesheuvel , Mark Rutland , Arnd Bergmann , Vincent Donnefort , Kristina Martsenko , Fuad Tabba , Joey Gouly , Akihiko Odaki , Jing Zhang , linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 2/7] arm64: KVM: Use shared area to pass PMU event state to hypervisor Message-ID: References: <20240104162714.1062610-1-james.clark@arm.com> <20240104162714.1062610-3-james.clark@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240104162714.1062610-3-james.clark@arm.com> X-Migadu-Flow: FLOW_OUT On Thu, Jan 04, 2024 at 04:27:02PM +0000, James Clark wrote: [...] > diff --git a/arch/arm64/kvm/hyp/nvhe/switch.c b/arch/arm64/kvm/hyp/nvhe/switch.c > index c50f8459e4fc..89147a9dc38c 100644 > --- a/arch/arm64/kvm/hyp/nvhe/switch.c > +++ b/arch/arm64/kvm/hyp/nvhe/switch.c > @@ -130,13 +130,18 @@ static void __hyp_vgic_restore_state(struct kvm_vcpu *vcpu) > } > } > > +static struct kvm_pmu_events *kvm_nvhe_get_pmu_events(struct kvm_vcpu *vcpu) > +{ > + return &kvm_host_global_state[vcpu->cpu].pmu_events; > +} > + > /* > * Disable host events, enable guest events > */ > #ifdef CONFIG_HW_PERF_EVENTS > static bool __pmu_switch_to_guest(struct kvm_vcpu *vcpu) > { > - struct kvm_pmu_events *pmu = &vcpu->arch.pmu.events; > + struct kvm_pmu_events *pmu = kvm_nvhe_get_pmu_events(vcpu); > > if (pmu->events_host) > write_sysreg(pmu->events_host, pmcntenclr_el0); > @@ -152,7 +157,7 @@ static bool __pmu_switch_to_guest(struct kvm_vcpu *vcpu) > */ > static void __pmu_switch_to_host(struct kvm_vcpu *vcpu) > { > - struct kvm_pmu_events *pmu = &vcpu->arch.pmu.events; > + struct kvm_pmu_events *pmu = kvm_nvhe_get_pmu_events(vcpu); > > if (pmu->events_guest) > write_sysreg(pmu->events_guest, pmcntenclr_el0); This now allows the host to program event counters for a protected guest. That _might_ be a useful feature behind some debug option, but is most definitely *not* something we want to do for pVMs generally. Do we even need to make this shared data work at all for pKVM? The rest of the shared data between pKVM and the kernel is system information, which (importantly) doesn't have any guest context in it. I'm perfectly happy leaving these sorts of features broken for pKVM and using the 'normal' way of getting percpu data to the nVHE hypervisor otherwise. -- Thanks, Oliver