From patchwork Tue Jul 18 16:45:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jing Zhang X-Patchwork-Id: 13318285 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 9310FEB64DA for ; Wed, 19 Jul 2023 06:07:05 +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:Cc:To:From:Subject:Message-ID: Mime-Version:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=ndpC8NvqJa5POMv4cL3MIKZvjccFOMPGSUlGyT1210s=; b=39C EEFT+W4sFhefcONAz9q70TxWFq6u0CQszkLcTdsgrgvgfBZzwxiiovLc24gPpPEghbmz0X9CQuTSF 86ZvSQLyvKwBt/qk5G5ct+6P9f7rNM1+JyzH1NJ25MJ452dXaK+JaNOfxwErYCJKMNienflRsoprq 1RPcOEolkG4nEkLlS3U/Xsom15ib6Hz3i7jeqb1TwaMFg9KKhGGxY2ouDvQOi9TWBBCDyHilngkHe txq1R/BroIBBiue/2UQFGTny1SkXevlsL7T22GZUlSd60XOyA9tJWypXYMRv1FOViS7aKWB/vckmM C5gsXuvNzqGH7k4mp+9XlVFMBrIfHWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qM0Kl-005YAO-2i; Wed, 19 Jul 2023 06:06:47 +0000 Received: from desiato.infradead.org ([90.155.92.199]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qM0Kk-005Y95-1W for linux-arm-kernel@bombadil.infradead.org; Wed, 19 Jul 2023 06:06:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Cc:To:From:Subject: Message-ID:Mime-Version:Date:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To:References; bh=6AIDMbL3hEpqRvQeU0o8z9v91gj2Rs+jacVKOsuLanM=; b=oRdrI4eWl123tWg2UAUjKaoEQp Kyrt0NVgg3pjNapGcXB7MPAI/puj6RrL+NpYUmHGDdCoDBJesoNdHaBhUpQIwRh5HOaw/qqx5Xbcw stW5lodoZdy+RAgV5NpqRbAIf5oGkVSttc0xcyuId8yNiZ+P/nCBE9PrtYRS0kKBCNTCa7oXUnZKg uiOLkLlZjnZyLHLdXf1X23zsAR05rmEx/xlnI6uUUTfDaqKk3UEkizNGZYQFTeK0C7+Y2XmHC8j7E slX7Qs0LNrEhbXMU1YiVERDDq932vws+ckT9Fgi8kbD2rAJGDjH9UN5NH47gTzdPSU53FeXx8jWMO BcnUPFHQ==; Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qLnrH-00BlUS-0f for linux-arm-kernel@lists.infradead.org; Tue, 18 Jul 2023 16:47:33 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5834d9ec5f7so21140727b3.1 for ; Tue, 18 Jul 2023 09:47:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689698727; x=1692290727; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=6AIDMbL3hEpqRvQeU0o8z9v91gj2Rs+jacVKOsuLanM=; b=GwJyCXzwR8CEZmqyx6/IbWlPjPDJ1FxZpeRJ3wqbqbOG/gJxyrN8HyggeYgPZ+Rv/m O3+vWONnwCm9msB1wWpFjzvdhvvWrFyfdsnmkcKymePAWa2+lVtm7aYQpith7CDZ72+n cBC4tXR59cAoilvguYVbzQ2QIR9KqbrJjMP19RBlLOmLM0KRzACHF2Uc/9r7gDqBvOZo lVVGgjsKNEVqh6pHHqWlwBxSfpU6Ro9ZuHOVCDyb9gQeJjSejHvMvkrrzOdOQbELcIoG kYhOwIjV+dtZQUEXh7a5HQreKIu+SIj8WH7HH9+4Zit/4rmOicw/wBB8WQ08vPEu5F+/ mfwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689698727; x=1692290727; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=6AIDMbL3hEpqRvQeU0o8z9v91gj2Rs+jacVKOsuLanM=; b=BClqIxd0Hluia512SZrG8O8Otz4sagfFeG5CD6DinAlYmNVfxwqZb46lHkfamOkAMm u1lWZozkyeKOFUGyEatxSBBi4yw87HxzOxN5T1me97xUyW+HcopwQso464nqNgp7UIvz vigzWS2xRt4EuDa6MfVrxu+DOhZkFI2OE08QE7J+pryQRN8ck/9mAEeFdWqMtgpz2pup w+h24/Wanf13vootZUQZ8wycwjIadAzWI7+R+GMjg2SCfehD/kIBm1jxyOWvxaJhfAyz 8ZZR2TawQebxlpymA4/0rHcRawNWXtpCIrcaxGNB+NjV4Rj9JeYxcJTVAUwZvHjr6+4s V/ag== X-Gm-Message-State: ABy/qLYekvuNTak7JfRNP/qh943U0VbzQgxP2g5293spMdjwQOwKzsNv VifQAvcoA7lEY4ejOK/VhQEewPJu7JETWg3JuA== X-Google-Smtp-Source: APBJJlEE7YSo1kc58LaaioaXSeeq2+jodtyrKh2yayZZUrizGXuZuzM/qR6D7wkKJGnhlEDKp80fvQgvXoMdys1aaQ== X-Received: from jgzg.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1acf]) (user=jingzhangos job=sendgmr) by 2002:a05:690c:3003:b0:577:6462:24c3 with SMTP id ey3-20020a05690c300300b00577646224c3mr216939ywb.4.1689698726826; Tue, 18 Jul 2023 09:45:26 -0700 (PDT) Date: Tue, 18 Jul 2023 16:45:16 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.41.0.255.g8b1d071c50-goog Message-ID: <20230718164522.3498236-1-jingzhangos@google.com> Subject: [PATCH v6 0/6] Enable writable for idregs DFR0,PFR0, MMFR{0,1,2, 3} From: Jing Zhang To: KVM , KVMARM , ARMLinux , Marc Zyngier , Oliver Upton Cc: Will Deacon , Paolo Bonzini , James Morse , Alexandru Elisei , Suzuki K Poulose , Fuad Tabba , Reiji Watanabe , Raghavendra Rao Ananta , Suraj Jitindar Singh , Cornelia Huck , Jing Zhang X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230718_174731_348971_58062D83 X-CRM114-Status: UNSURE ( 9.10 ) X-CRM114-Notice: Please train this message. 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch series enable userspace writable for below idregs: ID_AA64DFR0_EL1, ID_DFR0_EL1, ID_AA64PFR0_EL1, ID_AA64MMFR{0, 1, 2, 3}_EL1. It is based on v6.5-rc1 which contains infrastructure for writable idregs. A selftest is added to verify that KVM handles the writings from user space correctly. A relevant patch from Oliver is picked from [3]. --- * v5 -> v6 - Override the type of field AA64DFR0_EL1_DebugVer to be FTR_LOWER_SAFE by the discussion of Oliver and Suraj. * v4 -> v5 - Rebase on v6.4-rc1 which contains infrastructure for writable idregs. - Use guest ID registers values for the sake of emulation. - Added a selftest to verify idreg userspace writing. * v3 -> v4 - Rebase on v11 of writable idregs series at [2]. * v2 -> v3 - Rebase on v6 of writable idregs series. - Enable writable for ID_AA64PFR0_EL1 and ID_AA64MMFR{0, 1, 2}_EL1. * v1 -> v2 - Rebase on latest patch series [1] of enabling writable ID register. [1] https://lore.kernel.org/all/20230402183735.3011540-1-jingzhangos@google.com [2] https://lore.kernel.org/all/20230602005118.2899664-1-jingzhangos@google.com [3] https://lore.kernel.org/kvmarm/20230623205232.2837077-1-oliver.upton@linux.dev [v1] https://lore.kernel.org/all/20230326011950.405749-1-jingzhangos@google.com [v2] https://lore.kernel.org/all/20230403003723.3199828-1-jingzhangos@google.com [v3] https://lore.kernel.org/all/20230405172146.297208-1-jingzhangos@google.com [v4] https://lore.kernel.org/all/20230607194554.87359-1-jingzhangos@google.com [v5] https://lore.kernel.org/all/20230710192430.1992246-1-jingzhangos@google.com --- Jing Zhang (5): KVM: arm64: Use guest ID register values for the sake of emulation KVM: arm64: Enable writable for ID_AA64DFR0_EL1 and ID_DFR0_EL1 KVM: arm64: Enable writable for ID_AA64PFR0_EL1 KVM: arm64: Enable writable for ID_AA64MMFR{0, 1, 2, 3}_EL1 KVM: arm64: selftests: Test for setting ID register from usersapce Oliver Upton (1): KVM: arm64: Reject attempts to set invalid debug arch version arch/arm64/kvm/sys_regs.c | 84 +++++++-- tools/testing/selftests/kvm/Makefile | 1 + .../selftests/kvm/aarch64/set_id_regs.c | 163 ++++++++++++++++++ 3 files changed, 232 insertions(+), 16 deletions(-) create mode 100644 tools/testing/selftests/kvm/aarch64/set_id_regs.c base-commit: 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5