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 562E1C54E58 for ; Mon, 18 Mar 2024 18:23:13 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:Message-ID:In-Reply-To: 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=z/vbo3EnHeRd20u+QWETIiOCj12XR6fkrAB9urtB3o8=; b=4sI/7NyM6zTKZcdWq/kxEQO1hA lJ4lq+jnu8MGrQKNpPZORl6AAtH+IMBhJ5sO+uSR0B2cRJIsr3ZibiXJzJ7l5IDVJzcDzhEaKtpuI ynO8v4RjlfuyKAHKMNH0PqWe98tdUGf59o3ByeyqDYTrfMO9wrNxIzY0g4D/zrUTuh/cnVO31y8mf abb90gIm1/gRI7ojrl+kQgaI1qpHgo4BTT/Ng+tpSjnIysTaksKmEbcKKrVWGkaRQCEf5k94sHK+d 5lfIGNNTbLQpsUqoDDxXgDWmENK1yyUyw80KaYSEgrZ5+4k/+asGiWqhlqFE+qKKK7niYmdhhJ9Pk V8t3sy7g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rmHdV-00000009eoN-0o6M; Mon, 18 Mar 2024 18:23:01 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rmHdR-00000009enC-2A4V for linux-arm-kernel@lists.infradead.org; Mon, 18 Mar 2024 18:22:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710786176; 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=yFFKA6y67Rz7TxD708RZgne+A5RP9HKNuI5/NcqRuto=; b=FzSrkuymz+O/f7crWpxz6A++6zKSbWuo4Y/un8heTgoqdvJ4shjzHaYX6v9YIpTuos7QAt hAJh2S+JWbA9Vw6t7FGejIfw0xOeXQBeBsv/HzgfHaQFpp7at9Oe5UFTwMx0E1DDKJM2ZF FO6lAoFrD+p262XBzVkqWgIsJvv7KLY= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-199-FEoA3VM_MSaaO6OoEAacog-1; Mon, 18 Mar 2024 14:22:54 -0400 X-MC-Unique: FEoA3VM_MSaaO6OoEAacog-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4140408c7faso16477735e9.1 for ; Mon, 18 Mar 2024 11:22:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710786174; x=1711390974; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yFFKA6y67Rz7TxD708RZgne+A5RP9HKNuI5/NcqRuto=; b=ApnBAnOkq31SQrf2j9KVOwbxLxOv4pqPJR+n1Lo4b8y5mGIAMksvDjGHivjgr3mIe8 nA1w1DtG2epDesEkcxmzciA65A4x6Mky1G2wjCSwuNsv7erTcJh/sNCiW4+zHp1V08ca lbaLA2xXs6IOEpVPF5geWHiTS3IGoC0r9j2I8glyjE+jxnYwgLWZQbjezYSXjcM2Vv9I YcKIHhHhJrdAghXFTLWEi7gA5g6szLYXhxDjwfEe69chY6FHkAklxVZ47fqaYuMIee84 uTbk8nnOBtJA0XKqUAXU+q/NW3+6r3zBNCxuE+n9Yi3j4ogW/Zdlg9ybGFzJ9HFMNwU3 dKwQ== X-Gm-Message-State: AOJu0Ywxmgm1vKbv+yHu88OO83vtY0Dxf8ul9nfF6Ie6fc2WwZEWyNZn AUhebsKr2DPwRgtUFmw2AJKYDg2YlR1VuUa/OjtYf7Kjf8vrEvncuRCsOMZGuUAC2xcgPG73SmB 3uOEXr/THYoGym9pHvj6i2v+Lo1Da2iuldkBhpnhDDmRJ0A43MZueiNrey96im/EXp5D4ml0p X-Received: by 2002:a05:600c:3baa:b0:413:e987:d377 with SMTP id n42-20020a05600c3baa00b00413e987d377mr9205182wms.16.1710786173835; Mon, 18 Mar 2024 11:22:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGD1/bzDMWzK7Vjn7kuQjH1L7QA7mNLjYK2aZoR+UhFNDmIUqU6CqQ09CPUCcGhlVV+CWyJNg== X-Received: by 2002:a05:600c:3baa:b0:413:e987:d377 with SMTP id n42-20020a05600c3baa00b00413e987d377mr9205172wms.16.1710786173515; Mon, 18 Mar 2024 11:22:53 -0700 (PDT) Received: from rh (p200300c93f079e00cac8703672d98936.dip0.t-ipconnect.de. [2003:c9:3f07:9e00:cac8:7036:72d9:8936]) by smtp.gmail.com with ESMTPSA id f19-20020a05600c155300b00414105c4cd9sm4034931wmg.21.2024.03.18.11.22.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 11:22:53 -0700 (PDT) Date: Mon, 18 Mar 2024 19:22:52 +0100 (CET) From: Sebastian Ott To: Marc Zyngier cc: linux-arm-kernel@lists.infradead.org, Oliver Upton Subject: Re: [PATCH 3/4] KVM: arm64: show writable masks for feature registers In-Reply-To: <86zfuvzr0n.wl-maz@kernel.org> Message-ID: References: <20240318111636.10613-1-sebott@redhat.com> <20240318111636.10613-4-sebott@redhat.com> <86zfuvzr0n.wl-maz@kernel.org> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240318_112257_676271_1D32C535 X-CRM114-Status: GOOD ( 23.74 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, 18 Mar 2024, Marc Zyngier wrote: > On Mon, 18 Mar 2024 11:16:35 +0000, > Sebastian Ott wrote: >> >> Instead of using ~0UL provide the actual writable mask for >> non-id feature registers in the output of the >> KVM_ARM_GET_REG_WRITABLE_MASKS ioctl. > > CTR_EL0 definitely seems to be in the feature ID range. And so does > CLIDR_EL1. Sry, bad wording. I mean feature id regs for which is_id_reg() is false. >> >> This changes the mask for the CTR_EL0 register. > > Only that? Yes. >> Signed-off-by: Sebastian Ott >> --- >> arch/arm64/kvm/sys_regs.c | 21 ++++++--------------- >> 1 file changed, 6 insertions(+), 15 deletions(-) >> >> diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c >> index b2019faa9d73..0f8fe7790c35 100644 >> --- a/arch/arm64/kvm/sys_regs.c >> +++ b/arch/arm64/kvm/sys_regs.c >> @@ -2489,12 +2489,12 @@ static const struct sys_reg_desc sys_reg_descs[] = { >> >> { SYS_DESC(SYS_CCSIDR_EL1), access_ccsidr }, >> { SYS_DESC(SYS_CLIDR_EL1), access_clidr, reset_clidr, CLIDR_EL1, >> - .set_user = set_clidr }, >> + .set_user = set_clidr, .val = ~0UL }, > > How is CLIDR_EL1 (and all the crap that depend on it) recomputed when > CTR_EL0 is changed? Do we have means to handle dependencies here? There is no natural order in which userspace is writing to these regs. Nor a good time or a trigger when the kernel should do a sanity/dependency check.. > >> { SYS_DESC(SYS_CCSIDR2_EL1), undef_access }, >> { SYS_DESC(SYS_SMIDR_EL1), undef_access }, >> { SYS_DESC(SYS_CSSELR_EL1), access_csselr, reset_unknown, CSSELR_EL1 }, >> { SYS_DESC(SYS_CTR_EL0), access_ctr, .reset = reset_ctr, >> - .get_user = get_ctr, .set_user = set_ctr}, >> + .get_user = get_ctr, .set_user = set_ctr, .val = CTR_EL0_DIC_MASK}, > > This is all extremely fragile. We need a better solution for this. And > we need far more than just DIC here. > >> { SYS_DESC(SYS_SVCR), undef_access }, >> >> { PMU_SYS_REG(PMCR_EL0), .access = access_pmcr, .reset = reset_pmcr, >> @@ -3934,20 +3934,11 @@ int kvm_vm_ioctl_get_reg_writable_masks(struct kvm *kvm, struct reg_mask_range * >> if (!is_feature_id_reg(encoding) || !reg->set_user) >> continue; >> >> - /* >> - * For ID registers, we return the writable mask. Other feature >> - * registers return a full 64bit mask. That's not necessary >> - * compliant with a given revision of the architecture, but the >> - * RES0/RES1 definitions allow us to do that. >> - */ >> - if (is_id_reg(encoding)) { >> - if (!reg->val || >> - (is_aa32_id_reg(encoding) && !kvm_supports_32bit_el0())) >> - continue; >> - val = reg->val; >> - } else { >> - val = ~0UL; >> + if (!reg->val || >> + (is_aa32_id_reg(encoding) && !kvm_supports_32bit_el0())) { >> + continue; >> } >> + val = reg->val; > > Are CLIDR_EL1 and CTR_EL0 the only two ID registers that had a > set_user callback without an encoded mask? These 2 are the only regs affected by this patch - meaning !is_id_reg() && reg->set_user && !reg->val _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel