Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp55945rdb; Fri, 29 Sep 2023 16:36:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEtVf/Hbtxa9Pr3yejjfaR9b6PdXiBpKkJ1fQBcDVGN9CM3YPMMun0wt1DYzgVHJuouNSxb X-Received: by 2002:a05:6358:4404:b0:13a:9d5:356a with SMTP id z4-20020a056358440400b0013a09d5356amr6067214rwc.21.1696030602379; Fri, 29 Sep 2023 16:36:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696030602; cv=none; d=google.com; s=arc-20160816; b=loxGwYunW1td039bCDX2RrRCFCpq5xwKHSxGrFMWPlUEDRx1q729Te7bDmJ5iSxq04 bzwvGEoLyoKImNgS37s3cI70i26ERKmqwJxophu3rVnM/eqFKnzfKVrJqZn/+ogCjJ43 xL08MyuG8YYAJ/BNpjFlYDckbI6ZUwJMGrJl319cRlXjZm1SNr3CXWPJyqp5fW0LGZa7 T63f3Ttg6qKervH7uP5WvySwbACDBbaQgI4sKKDYp8/S6VCrX0Ww7xzDPDP4eeHHb3xc p9TyTXbnu3JLa9Ay6f6PEzV8tmZ2CsYxgPo34gBBQZs40xMYWeRT2Pfg4nTVZ9eCKwtb ACJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=hEGFAwORKfsvdgrCcVd+UUjZF6l0U2fhYj6xzLXT72Y=; fh=XENNrrodVer2MnsjeS6LWUgQ7xVUDDNWZmMfEsUgLa8=; b=U26Nj3iKa99yst8+m9Dx2DrmGXNYPisQ1l9/OuR4TRkkTaTkUbT6W6kdSrAl4Li1J5 acA/GCY1TDsJwCY6/tBbdOBh6sLQSABBBcvN45P6WMeKxHzqhuYKIVSgdbgzEaVNiYsB 8k/96w5we0Y6xBpzXISLWiN8cX4QNc2Q4wBEcnhTGJ67Ws5Y56DW/pkRSimw4x60lSfy c/SyDqnGMHoPghlFeLlfDkspkCI94NFDzai01ehpj6vAlApV9teeiO1cZMLQNWx8vquu OAk6agqHBM+hC1fgu1DKWK9K3Cd3wlF29PPAHF7VQTqtQBETBdTTpjS26WtZMFWv3Vuj Vefg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fnHaVr4Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id t22-20020a056a0021d600b0068bf645ac9bsi22969461pfj.238.2023.09.29.16.36.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 16:36:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fnHaVr4Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id C3ED28386439; Fri, 29 Sep 2023 08:09:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233464AbjI2PJm (ORCPT + 99 others); Fri, 29 Sep 2023 11:09:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230104AbjI2PJl (ORCPT ); Fri, 29 Sep 2023 11:09:41 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F01FC1A7 for ; Fri, 29 Sep 2023 08:08:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696000131; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hEGFAwORKfsvdgrCcVd+UUjZF6l0U2fhYj6xzLXT72Y=; b=fnHaVr4ZVRlpSGBlCw5GofRth91NtPlTZhNG8XJ+eK33Qqj6aeMscB9yo1vw8cVU8f093b FI3pl/y2aT15Ser2TmRrkQAPwB0ud6vh1QVo5JwihFIHcXfnsvADOGNPONl0LjZ7fJ0JEQ uaTo+512S3NeXrECLKaTDxdNwAtab/Y= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-680-BYtjnLMLOIOI1ui41DVZEA-1; Fri, 29 Sep 2023 11:08:49 -0400 X-MC-Unique: BYtjnLMLOIOI1ui41DVZEA-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-65b23c40cefso109401076d6.1 for ; Fri, 29 Sep 2023 08:08:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696000128; x=1696604928; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hEGFAwORKfsvdgrCcVd+UUjZF6l0U2fhYj6xzLXT72Y=; b=LHOzAWUHHrJbNL1y3Cj+rbwjsuO4TrRqGBKQwhfTWuLTyuGcuz0eqyq4Tntr77GIba 4A68zHMjIfkhSy8OIRPwZBh/ccnGbAiEVj6Y0ys66Q8SL0F1dMm/ulf82P9m8VjVS/IP 6UYZzXx3tCkTQFoeHolXHVf7qbx4nf4UtNrmhdiucGs7iVgqug/+WWc0fQ2VYEeXsr/+ Ea0xtX3NeKLMqERJKT9oe5zeOZid6pNVnoSiDi06NPLIi0wEMPsWxCil4FnZsmG5PfAr ql+8M1MH2YHDBgJMFjJQZK/btBL1M815ElKfrkaAG51EIw9M2SArEIDZMr3tcvKg67YS 690Q== X-Gm-Message-State: AOJu0Yyd5FFaGtEg+azPdZLOVv1SVYGkusTj8zSYjiGiFAwG9Ye5tUpU BJXoW6VCx0STVHIlZjBbsSKyhfgrPzY/zyJrBBEgsd5ehG5avn1unDOoC7bj7X5nPjp/8noIIsh iCXb2vt7yvWwQJkmLY4WXmudN X-Received: by 2002:a05:6214:5195:b0:656:3895:fcf9 with SMTP id kl21-20020a056214519500b006563895fcf9mr5233552qvb.32.1696000128456; Fri, 29 Sep 2023 08:08:48 -0700 (PDT) X-Received: by 2002:a05:6214:5195:b0:656:3895:fcf9 with SMTP id kl21-20020a056214519500b006563895fcf9mr5233520qvb.32.1696000128081; Fri, 29 Sep 2023 08:08:48 -0700 (PDT) Received: from ?IPV6:2a01:e0a:59e:9d80:527b:9dff:feef:3874? ([2a01:e0a:59e:9d80:527b:9dff:feef:3874]) by smtp.gmail.com with ESMTPSA id a10-20020a0ce38a000000b0063f88855ef2sm3377788qvl.101.2023.09.29.08.08.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Sep 2023 08:08:47 -0700 (PDT) Message-ID: Date: Fri, 29 Sep 2023 17:08:42 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v2 2/2] arm64/kvm: Fine grain _EL2 system registers list that affect nested virtualization Content-Language: en-US To: Miguel Luis , Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev References: <20230925162057.27548-1-miguel.luis@oracle.com> <20230925162057.27548-3-miguel.luis@oracle.com> From: Eric Auger In-Reply-To: <20230925162057.27548-3-miguel.luis@oracle.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.1 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 29 Sep 2023 08:09:52 -0700 (PDT) Hi Miguel, On 9/25/23 18:20, Miguel Luis wrote: > Some _EL1 registers got included in the _EL2 ranges, which are not if they aren't too many, you may list them as it eases the review > affected by NV. Remove them, fine grain the ranges to exclusively > include the _EL2 ones and fold SPSR/ELR _EL2 registers into the > existing range. > > Signed-off-by: Miguel Luis Fixes: d0fc0a2519a6 (" KVM: arm64: nv: Add trap forwarding for HCR_EL2") ? > --- > arch/arm64/kvm/emulate-nested.c | 44 ++++++++++++++++++++++++++++----- > 1 file changed, 38 insertions(+), 6 deletions(-) > > diff --git a/arch/arm64/kvm/emulate-nested.c b/arch/arm64/kvm/emulate-nested.c > index 9ced1bf0c2b7..f6d0c87803f4 100644 > --- a/arch/arm64/kvm/emulate-nested.c > +++ b/arch/arm64/kvm/emulate-nested.c > @@ -649,14 +649,46 @@ static const struct encoding_to_trap_config encoding_to_cgt[] __initconst = { > SR_TRAP(SYS_APGAKEYHI_EL1, CGT_HCR_APK), > /* All _EL2 registers */ > SR_RANGE_TRAP(sys_reg(3, 4, 0, 0, 0), > - sys_reg(3, 4, 3, 15, 7), CGT_HCR_NV), > + sys_reg(3, 4, 4, 0, 1), CGT_HCR_NV), > /* Skip the SP_EL1 encoding... */ > - SR_TRAP(SYS_SPSR_EL2, CGT_HCR_NV), > - SR_TRAP(SYS_ELR_EL2, CGT_HCR_NV), > - SR_RANGE_TRAP(sys_reg(3, 4, 4, 1, 1), > - sys_reg(3, 4, 10, 15, 7), CGT_HCR_NV), I am not sure I fully understand the sysreg encoding but globally there are not so many _EL2 regs trapped with .NV. And I can see holes within somes ranges defined above (I searched all "if EL2Enabled() && HCR_EL2.NV == '1' then" in the ARM ARM). Maybe I don't know how to use the ARM ARM doc but I feel difficult to understand if the "holes" within the encoding of some ranges are unused or are allocated to some other sysregs, which wouldn't be trapped by /NV. I fear range encoding may be quite risky. > + SR_RANGE_TRAP(sys_reg(3, 4, 4, 3, 0), > + sys_reg(3, 4, 10, 6, 7), CGT_HCR_NV), > + /* > + * Note that the spec. describes a group of MEC registers > + * whose access should not trap, therefore skip the following: > + * MECID_A0_EL2, MECID_A1_EL2, MECID_P0_EL2, > + * MECID_P1_EL2, MECIDR_EL2, VMECID_A_EL2, > + * VMECID_P_EL2. > + */ > SR_RANGE_TRAP(sys_reg(3, 4, 12, 0, 0), > - sys_reg(3, 4, 14, 15, 7), CGT_HCR_NV), > + sys_reg(3, 4, 12, 1, 1), CGT_HCR_NV), > + /* ICH_AP0R_EL2 */ > + SR_RANGE_TRAP(SYS_ICH_AP0R0_EL2, > + SYS_ICH_AP0R3_EL2, CGT_HCR_NV), > + /* ICH_AP1R_EL2 */ > + SR_RANGE_TRAP(SYS_ICH_AP1R0_EL2, > + SYS_ICH_AP1R3_EL2, CGT_HCR_NV), > + SR_RANGE_TRAP(sys_reg(3, 4, 12, 9, 5), > + sys_reg(3, 4, 12, 11, 7), CGT_HCR_NV), > + /* ICH_LR_EL2 */ > + SR_RANGE_TRAP(SYS_ICH_LR0_EL2, > + SYS_ICH_LR7_EL2, CGT_HCR_NV), > + SR_RANGE_TRAP(SYS_ICH_LR8_EL2, > + SYS_ICH_LR15_EL2, CGT_HCR_NV), > + SR_RANGE_TRAP(sys_reg(3, 4, 13, 0, 1), > + sys_reg(3, 4, 13, 0, 7), CGT_HCR_NV), > + /* AMEVCNTVOFF0_EL2 */ > + SR_RANGE_TRAP(sys_reg(3, 4, 13, 8, 0), > + sys_reg(3, 4, 13, 8, 7), CGT_HCR_NV), > + SR_RANGE_TRAP(sys_reg(3, 4, 13, 9, 0), > + sys_reg(3, 4, 13, 9, 7), CGT_HCR_NV), I think those 2 above ranges can be merged > + /* AMEVCNTVOFF1_EL2 */ > + SR_RANGE_TRAP(sys_reg(3, 4, 13, 10, 0), > + sys_reg(3, 4, 13, 10, 7), CGT_HCR_NV), > + SR_RANGE_TRAP(sys_reg(3, 4, 13, 11, 0), > + sys_reg(3, 4, 13, 11, 7), CGT_HCR_NV), /* CNT*_EL2 */ > + SR_RANGE_TRAP(sys_reg(3, 4, 14, 0, 3), > + sys_reg(3, 4, 14, 5, 2), CGT_HCR_NV), > /* All _EL02, _EL12 registers */ > SR_RANGE_TRAP(sys_reg(3, 5, 0, 0, 0), > sys_reg(3, 5, 10, 15, 7), CGT_HCR_NV), not related to your patch but wrt the EL02 the only ones that I idenftied beeing trapped by NV using above search are CNTP_TVAL_EL02 3 5 14 2 0 CNTP_CTL_EL02 3 5 14 2 1 CNTP_CVAL_EL02 3 5 14 2 2 CNTV_TVAL_EL02 3 5 14 3 0 CNTV_CTL_EL02 3 5 14 3 1 CNTV_CVAL_EL02 3 5 14 3 2 Thanks Eric