From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2BB25C4345F for ; Wed, 1 May 2024 06:51:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fcCYwa+Fd7wL7chjT0xUZ50GwbNlVb8CMvHzRAyMe9c=; b=rAibvcBVQJWByK bqkjAYNKjwZrttFh/nGgf8SqWMPxHk3sON7G9HBIv/cfOsiDiHZPfCK4u6Ihp/w7oxkAsHzkbFklb 6VFm2aMhSXxE9nJrYKE3I1Qjb6JUg4T1cG0XwxASmtFdHuEXW87oLymgMiRCPz7YIB5eO155KdCqD dWIw+rif3ZzxabE/620JhLlsvZi/5C7t3XoqBqf9NN1jziTNqkaSo9+GOBKp6MjOW53rH0HVkxHyQ O2WQ/g/OoPvX0MiunMnCYO3IJV+Lt4XncxnY1SN1b9uYX8HpDHs8Ss1ggy6ynm604M9U9IjlB44p6 YqIvtwSAJYGlTo+PSLiA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s23oY-00000008huZ-1fkW; Wed, 01 May 2024 06:51:38 +0000 Received: from out-188.mta1.migadu.com ([2001:41d0:203:375::bc]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s23oN-00000008hpj-0NxI for linux-arm-kernel@lists.infradead.org; Wed, 01 May 2024 06:51:36 +0000 Date: Wed, 1 May 2024 06:51:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1714546276; 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=CWi8bLLKtBukGh8G8zTTjC/3eWfwrHWDi/RHw99/oFY=; b=Ai3adrx8ClVvRwCA5urG/wBGSd0ZhpkPcliTI60FIvrx2jdMTcNTcAPxsu/H5gFxBmbKct WekqzR6yVfJLEqbAbu94jAWErnYXS1SV3YjuwOsusm1bkYZTEYOziCbwNY+whcWNh9JDRt P+Mfa/SaYLqy2nox9/YFZIiaU7wSGhg= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Sebastian Ott Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, Marc Zyngier , James Morse , Suzuki K Poulose , Catalin Marinas , Will Deacon Subject: Re: [PATCH v2 2/6] KVM: arm64: unify trap setup code Message-ID: References: <20240426104950.7382-1-sebott@redhat.com> <20240426104950.7382-3-sebott@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240426104950.7382-3-sebott@redhat.com> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240430_235128_040803_3A1C4B40 X-CRM114-Status: GOOD ( 12.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Apr 26, 2024 at 12:49:46PM +0200, Sebastian Ott wrote: > There are 2 functions to set up traps via HCR_EL2: nitpick: these functions *calculate* the trap values, but do not actually set them up. HCR_EL2 doesn't get written to until further down the line on KVM_RUN. > + if (cpus_have_final_cap(ARM64_HAS_STAGE2_FWB)) { > + vcpu->arch.hcr_el2 |= HCR_FWB; > + } else { > + /* > + * For non-FWB CPUs, we trap VM ops (HCR_EL2.TVM) until M+C > + * get set in SCTLR_EL1 such that we can detect when the guest > + * MMU gets turned on and do the necessary cache maintenance > + * then. > + */ > + vcpu->arch.hcr_el2 |= HCR_TVM; > + } It seems to me like calling this once for the lifetime of a vCPU will break non-FWB behavior. Like the comment suggests, these traps are needed to catch the moment the S1 MMU is turned on and do cache maintenance to make sure D$ agrees with what the guest was doing before enabling the MMU. KVM_ARM_VCPU_INIT resets SCTLR_EL1, but it seems we'd miss setting HCR_TVM in that case. -- Thanks, Oliver _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel