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 2BD97C46467 for ; Thu, 19 Jan 2023 19:47:49 +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=azc/G5ZjllddRUbDBYRsRumveAHyuQDFdmpfMuGP9Ys=; b=hW5mOhXeb1NSY5 IrMX5GNU/5Vk2vPZ58CXiQkpd95H9QN/wVBdAhEWAbS14h3jEK3ZHVX6aPL3tss6M9P8QUiCxI86V XG00cA21D/FIlR2j317TKLtw4B6KLuA+XJEHUu15U93vqQ4NhqDtJLEker5cnP3VfVF70y4UyzWaZ 9Sap/P0vWwDdXjcius4PD/dMXhsPpEX/OpYSfMXLmkrQbHXJBhX3NS/GO+KJkAE/QdSnDHizFSfLG DGoLEYLYA5+l6UcdPBFe6lq+dPekr2yikQ+nc2jHxKRLH8EDUOsgU968OFkYiT9AgXbrJpJJoNhIB drt602BPKsRothhrBF3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIarl-0072mO-3p; Thu, 19 Jan 2023 19:46:29 +0000 Received: from out0.migadu.com ([94.23.1.103]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIarf-0072jx-An for linux-arm-kernel@lists.infradead.org; Thu, 19 Jan 2023 19:46:25 +0000 Date: Thu, 19 Jan 2023 19:46:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1674157581; 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=Ny5pbFcUDicEKi2kQlKMNoopMQxdvl4TAC0NXH0FWZc=; b=lQclnKO49SxNR+ip+srDOZF4ojQRaxsKsDP61gap4s4i2v1bZmFg0XsAF39r6FsaTjUS3V V6lZh7A2hzM1Jefk9R1hMMoYohp4/1i8UM7GYMSopzrNUMbfTn5BqZ8vkBY4ajH8SrOu8l 7N7ix/3EhvbqAfTJqoe1qdMbq6iKJKE= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Akihiko Odaki Cc: Mark Brown , Marc Zyngier , linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Mathieu Poirier , Suzuki K Poulose , Alexandru Elisei , James Morse , Will Deacon , Catalin Marinas , asahi@lists.linux.dev, Alyssa Rosenzweig , Sven Peter , Hector Martin Subject: Re: [PATCH v7 7/7] KVM: arm64: Normalize cache configuration Message-ID: References: <20230112023852.42012-1-akihiko.odaki@daynix.com> <20230112023852.42012-8-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230112023852.42012-8-akihiko.odaki@daynix.com> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230119_114623_562122_2340F6C8 X-CRM114-Status: GOOD ( 16.65 ) 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 Hi Akihiko, On Thu, Jan 12, 2023 at 11:38:52AM +0900, Akihiko Odaki wrote: > Before this change, the cache configuration of the physical CPU was > exposed to vcpus. This is problematic because the cache configuration a > vcpu sees varies when it migrates between vcpus with different cache > configurations. > > Fabricate cache configuration from the sanitized value, which holds the > CTR_EL0 value the userspace sees regardless of which physical CPU it > resides on. > > CLIDR_EL1 and CCSIDR_EL1 are now writable from the userspace so that > the VMM can restore the values saved with the old kernel. > > Suggested-by: Marc Zyngier > Signed-off-by: Akihiko Odaki I needed to squash in the patch below to get all of this working. Writing back the value read for a given cache level was failing, which I caught with the get-reg-list selftest. Pushed the result here if you want to have a look: https://github.com/oupton/linux/tree/kvm-arm64/virtual-cache-geometry -- Thanks, Oliver diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 459e6d358dab..b6228f7d1d8d 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -148,17 +148,19 @@ static u32 get_ccsidr(struct kvm_vcpu *vcpu, u32 csselr) static int set_ccsidr(struct kvm_vcpu *vcpu, u32 csselr, u32 val) { - u8 line_size = FIELD_GET(CCSIDR_EL1_LineSize, val); + u8 line_size = SYS_FIELD_GET(CCSIDR_EL1, LineSize, val); + u32 cur = get_ccsidr(vcpu, csselr); + u8 min_line_size = SYS_FIELD_GET(CCSIDR_EL1, LineSize, cur); u32 *ccsidr = vcpu->arch.ccsidr; u32 i; - if ((val & CCSIDR_EL1_RES0) || line_size < get_min_cache_line_size(csselr)) + if (cur == val) + return 0; + + if ((val & CCSIDR_EL1_RES0) || line_size < min_line_size) return -EINVAL; if (!ccsidr) { - if (val == get_ccsidr(vcpu, csselr)) - return 0; - ccsidr = kmalloc_array(CSSELR_MAX, sizeof(u32), GFP_KERNEL); if (!ccsidr) return -ENOMEM; _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel