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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DB8AEB64DD for ; Tue, 27 Jun 2023 16:36:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229797AbjF0Qg1 (ORCPT ); Tue, 27 Jun 2023 12:36:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229923AbjF0Qg0 (ORCPT ); Tue, 27 Jun 2023 12:36:26 -0400 Received: from out-22.mta0.migadu.com (out-22.mta0.migadu.com [91.218.175.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91CC0E3 for ; Tue, 27 Jun 2023 09:36:25 -0700 (PDT) Date: Tue, 27 Jun 2023 16:36:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1687883781; 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=TdPWXSyjblV3/5xOatcCVLPo7q0/XX1p8z7/HRrMyY4=; b=EXIZVy5J6MxGX9EQ+OKpXpnnjbw5vcyBncQrLh1i58J5rK3yZEUFuI1CpFoLhqMING/XeP KXHTTGtwb2mpSmLdpYfZnQfT8KEgSBAzQk7Yr6uodNnP/9VUfXRhrmcb6YtTumqyh/1+1j WQz0gZ20fj54qKqWLkxZptQhaLjcGAQ= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Marc Zyngier Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, James Morse , Suzuki K Poulose , Zenghui Yu , stable@vger.kernel.org Subject: Re: [PATCH] KVM: arm64: timers: Use CNTHCTL_EL2 when setting non-CNTKCTL_EL1 bits Message-ID: References: <20230627140557.544885-1-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230627140557.544885-1-maz@kernel.org> X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Tue, Jun 27, 2023 at 03:05:57PM +0100, Marc Zyngier wrote: > It recently appeared that, whien running VHE, there is a notable > difference between using CNTKCTL_EL1 and CNTHCTL_EL2, despite what > the architecture documents: > > - When accessed from EL2, bits [19:18] and [16:10] same bits have > the same assignment as CNTHCTL_EL2 > - When accessed from EL1, bits [19:18] and [16:10] are RES0 > > It is all OK, until you factor in NV, where the EL2 guest runs at EL1. > In this configuration, CNTKCTL_EL11 doesn't trap, nor ends up in > the VNCR page. This means that any write from the guest affecting > CNTHCTL_EL2 using CNTKCTL_EL1 ends up losing some state. Not good. > > The fix it obvious: don't use CNTKCTL_EL1 if you want to change bits > that are not part of the EL1 definition of CNTKCTL_EL1, and use > CNTHCTL_EL2 instead. This doesn't change anything for a bare-metal OS, > and fixes it when running under NV. The NV hypervisor will itself > have to work harder to merge the two accessors. > > Note that there is a pending update to the architecture to address > this issue by making the affected bits UNKNOWN when CNTKCTL_EL1 is > user from EL2 with VHE enabled. > > Fixes: c605ee245097 ("KVM: arm64: timers: Allow physical offset without CNTPOFF_EL2") > Signed-off-by: Marc Zyngier > Cc: stable@vger.kernel.org # v6.4 Looks good. I'll probably open a fixes branch around -rc1 and pick this patch up then. -- Thanks, Oliver