Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5114229rwb; Sat, 10 Dec 2022 23:41:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf70regm6pBYXhkwdeTNfU9MK/PpfrnGSwk7o5KlctjMHFrc7b09/gA8IPzlxU8opx97XnDB X-Received: by 2002:a17:906:7209:b0:7ad:8057:4f06 with SMTP id m9-20020a170906720900b007ad80574f06mr9346400ejk.59.1670744485295; Sat, 10 Dec 2022 23:41:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670744485; cv=none; d=google.com; s=arc-20160816; b=pi0lNm2UN+9kUCvDXAygKpB59gmm+KOsJiKWWKEelFZOxGQ6S4G/pO7nxPwxoFUy2A w/llrJdvesVWorTYUN9GGXzCst+fgOgpT3MF19pNDgfbLziu7KBdPxwHm2W8KlnhMoX0 wJncxUFDc4+saQLfPzDMRF2ssRZOzGshiX27hvIJmiZAUW9iwJVYNEuayWKi9ohiEW4l BDHEact8GbE3qit3k0PYHwO98nQ4AbtzfFP78dEhMKnthOy28kxNG7WpIeD8A40ydRrn eaGgLYWsaMz10zKUlNYMh8ioxNCdkFDlA5ZlF2c80p5r4bB+tmfi3j9E4Q3s1L3/pxhn 86fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=0kPiXJlVEAGiE46bEmtCKOJ4JxdjDvz4UZE+PugYkgI=; b=Sge8Wy88qPx6ga5Uur0lxKt1v+fA+o9/Inkek0TWHo7crBdW6ZhsK5881GJU+nniPz 5aWJhUDKIVZXwVEsEs96jrgoxqgRjZksbf2G2frIcw6ZHN2iuyDZ9e3i0eCNhyGZTs3I TTGeCFhyYboDeyjnTwwG9a0J8Hea9MINLW4mfVZrmD7MkXE8GlhTC9cc9pi3nJAJ8O1R JJ+mu9k1PfEhUDEtReTTTRZBPLy0MGkVMKO2IYr97zA9zqWxtwX8uF6Goyszai0RGnRt 4rPyaBjoEtWRB4OdFLtWCfyJfisSAADV/Itv9gPykqz3JhzyEbDgYqusBhjXA3u9lW9B GTZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@daynix-com.20210112.gappssmtp.com header.s=20210112 header.b="zD/O2nzY"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g1-20020a170906394100b007c1027d92a1si3307053eje.292.2022.12.10.23.41.06; Sat, 10 Dec 2022 23:41:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@daynix-com.20210112.gappssmtp.com header.s=20210112 header.b="zD/O2nzY"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229896AbiLKFR3 (ORCPT + 75 others); Sun, 11 Dec 2022 00:17:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229796AbiLKFR0 (ORCPT ); Sun, 11 Dec 2022 00:17:26 -0500 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDE9613E3F for ; Sat, 10 Dec 2022 21:17:25 -0800 (PST) Received: by mail-pf1-x432.google.com with SMTP id 124so6452808pfy.0 for ; Sat, 10 Dec 2022 21:17:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=0kPiXJlVEAGiE46bEmtCKOJ4JxdjDvz4UZE+PugYkgI=; b=zD/O2nzY7tL6eshwIf3CeY/YAQIm1xVj5/Js/pKlVUvQWsGxQvosSXAL5bONw8IRja NA3S79/dHcWpJuvuy9trw6RuKm57YDQCUNFpPvtYLZhGO3nfFMIvpKzeGx8mjTPJk5gq hw+7ezvQrKhSUi9CIBPtmx5dqGx8b4Zr7z+xZLP2OUafjrWtcGD8PRS4P8yU7dKvr6Jv UbbqVz0qPUqc4J5QhHhE7EjNOtQ744qnzQYQZf3qc8NljImI96wFoAZ++URfZ7JtOOme i8w/sViehDGjCh8JEOb2IPC1RIyIsa1SCr8haVzrurKIBxrloDk0D0MMtViqlg2ivnDO D2tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0kPiXJlVEAGiE46bEmtCKOJ4JxdjDvz4UZE+PugYkgI=; b=Ol/qCAjqKegDOWQyT/Fy+X18798N8pABx/alJnLloBgempch2pUP98XJF1MK0XPFey Eqvk5fve7OYcJ7tUiCKzwkDjnuJ7Lu+8U+55HOZ1PIu2aCOufmrVzf2pZJS3bSLa2K0p 8z+c0U1KED6yvQnsMf3gvpB1WUl5ZXikmuVvKMLSFWj5R5YaK3HZQjKBCkfwZFfweW7l yii72aJ56RI41w3RAPZpjqZg1QqZV6QImRDpSk51rdFv+/DkmMnEvmFh1KH+A28L27ej /vpvS3i6nTNCFJePQnd7onX9tTkfMD5HqfPu6PMpE6SJr9UqocsxSsAXLGOxR1ZeRylV tb6g== X-Gm-Message-State: ANoB5pneW/7gxk0orNuxdGUlFq5lswLGxWx/V2jwrBukmPwnUhJ/wEvb DlL9cqlXrd0lt5EwMJ7clJxwvA== X-Received: by 2002:aa7:904e:0:b0:56b:a2f8:1d0f with SMTP id n14-20020aa7904e000000b0056ba2f81d0fmr9918822pfo.0.1670735845341; Sat, 10 Dec 2022 21:17:25 -0800 (PST) Received: from fedora.flets-east.jp ([2400:4050:c360:8200:8ae8:3c4:c0da:7419]) by smtp.gmail.com with ESMTPSA id f125-20020a623883000000b00575d90636dcsm3463684pfa.6.2022.12.10.21.17.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Dec 2022 21:17:25 -0800 (PST) From: Akihiko Odaki Cc: Marc Zyngier , linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Mathieu Poirier , Oliver Upton , Suzuki K Poulose , Alexandru Elisei , James Morse , Will Deacon , Catalin Marinas , asahi@lists.linux.dev, Alyssa Rosenzweig , Sven Peter , Hector Martin , Akihiko Odaki Subject: [PATCH 0/3] KVM: arm64: Normalize cache configuration Date: Sun, 11 Dec 2022 14:16:57 +0900 Message-Id: <20221211051700.275761-1-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 arm64_ftr_reg_ctrel0.sys_val, which holds the CTR_EL0 value the userspace sees regardless of which physical CPU it resides on. HCR_TID2 is now always set as it is troublesome to detect the difference of cache configurations among physical CPUs. CSSELR_EL1 is now held in the memory instead of the corresponding phyisccal register as the fabricated cache configuration may have a cache level which does not exist in the physical CPU, and setting the physical CSSELR_EL1 for the level results in an UNKNOWN behavior. CLIDR_EL1 and CCSIDR_EL1 are now writable from the userspace so that the VMM can restore the values saved with the old kernel. Akihiko Odaki (3): arm64/sysreg: Add CCSIDR2_EL1 arm64/cache: Move CLIDR macro definitions KVM: arm64: Normalize cache configuration arch/arm64/include/asm/cache.h | 6 + arch/arm64/include/asm/kvm_arm.h | 3 +- arch/arm64/include/asm/kvm_emulate.h | 4 - arch/arm64/include/asm/kvm_host.h | 6 +- arch/arm64/kernel/cacheinfo.c | 5 - arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h | 2 - arch/arm64/kvm/reset.c | 1 + arch/arm64/kvm/sys_regs.c | 232 ++++++++++++--------- arch/arm64/tools/sysreg | 5 + 9 files changed, 153 insertions(+), 111 deletions(-) -- 2.38.1