From nobody Wed Mar 12 03:48:56 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1728376720; cv=none; d=zohomail.com; s=zohoarc; b=cUl0ALILQfhLd0A7RODZiFMKGCDj6imj8YyHGnHIZUUs0v2N05ZKki7+TJbsEcT6V99sU9fwUfq+GQ58Mymor+zzViKhyzjJGXy5GbRfUKEm57/iOmQJjWVPp3eXiIky36IJUJhrEc/W/q5GDZpwv3jTAh17PJ2lG3MPOH9s+RY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728376720; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=m3rWamNd2rtptE3YePGwHSfGEHWYJhUnCLfE+jd0lUs=; b=X7OSYXVPJyiIxlF5Kl/Wmrr1GYuVbPuW9mUFxubMqAVWIfonvtxWtpTrcJcFhekePZdYKsTDV5e7M7s3LosJZqkHtH0l8H4qPRrHGjM7f1P+SacG/aQgCbdJiipFuMGe5cawy7IH1FtiZjTdg5PY1y+dLyWK78VC/hRr/OGejGw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1728376720815951.5815862618292; Tue, 8 Oct 2024 01:38:40 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.812803.1225555 (Exim 4.92) (envelope-from ) id 1sy5jP-0002CQ-DQ; Tue, 08 Oct 2024 08:38:11 +0000 Received: by outflank-mailman (output) from mailman id 812803.1225555; Tue, 08 Oct 2024 08:38:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sy5jP-0002CJ-9q; Tue, 08 Oct 2024 08:38:11 +0000 Received: by outflank-mailman (input) for mailman id 812803; Tue, 08 Oct 2024 08:38:09 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sy5jN-00027a-G6 for xen-devel@lists.xenproject.org; Tue, 08 Oct 2024 08:38:09 +0000 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [2a00:1450:4864:20::632]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a4a090be-8550-11ef-a0bc-8be0dac302b0; Tue, 08 Oct 2024 10:38:08 +0200 (CEST) Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-a9950d27234so291934866b.1 for ; Tue, 08 Oct 2024 01:38:07 -0700 (PDT) Received: from localhost ([213.195.117.215]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a993f13620dsm409753466b.215.2024.10.08.01.38.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 01:38:06 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a4a090be-8550-11ef-a0bc-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1728376687; x=1728981487; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=m3rWamNd2rtptE3YePGwHSfGEHWYJhUnCLfE+jd0lUs=; b=v8rZwZQNKXgclQq1EDr1ddKbNI1MHlSCIks68bEMDnL/Yj/XSn+P2scIA44H+Cy4qK 67cyvgLwKsGO31gp9C4A1xaCRjAa1HKzt+/0IW45cXNfu4m+hIjZA4EdtrhU8C2d4j3Q 4dTCwqFbJKw6UTIr7ErKkIJm+hq5lvGT8VUdw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728376687; x=1728981487; 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=m3rWamNd2rtptE3YePGwHSfGEHWYJhUnCLfE+jd0lUs=; b=DKVv9Uan/IrpOaU64IxOEdrscm/8/3/T+uYW4FOXSAmCh1j4M1YLPRNF+/YTGlnBVz w1D8izgwBHXGYrCGFQUEVKRarA5kx5wUBQYezb1IS62UBD02MUhUBeJKqYe/etczd+oy QHkuN3JOMfK++D5aWi6iO4T5ESN9/M71vbmevCQ9M4MqLUYcwKyVJ+3UFfHaXfQJ/ZOo cvS+rWHSzK0roKSMX2GiohUQfZyVheC6obrXOeavTueFthXIn09E3xe1DFAcuFRD6R8c DQSqYSIsZ04de19WaionIawtavnUmCS0t0+oJYxCyr8X9wTRRFWe0Uow0tCLoI1A3i5p BH+A== X-Gm-Message-State: AOJu0YxMTn/6irznasKyToYAWAOG5+Gg3+p/zZjjAvqlMxFREEI1YWRk CGdd8/zmG0mkQ1ZsijyMwx7oC5yeR0AXq391CYVCQ2p+Alpgturu+ETe+EuIelbFx2dtXzlw2Bi A X-Google-Smtp-Source: AGHT+IFZewXbZuFwWYvo/BnKc0vjjH0u4vA1EH8+3Nk1DBT90oUr5BgrimXMQU1AnM9Bmf41seUvXg== X-Received: by 2002:a17:907:9304:b0:a8d:7b7d:8c39 with SMTP id a640c23a62f3a-a991c03145bmr1519329266b.43.1728376687011; Tue, 08 Oct 2024 01:38:07 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper Subject: [PATCH] x86/domctl: fix maximum number of MSRs in XEN_DOMCTL_{get,set}_vcpu_msrs Date: Tue, 8 Oct 2024 10:37:55 +0200 Message-ID: <20241008083756.72829-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1728376722067116600 Since the addition of the MSR_AMD64_DR{1-4}_ADDRESS_MASK MSRs to the msrs_to_send array, the calculations for the maximum number of MSRs that the hypercall can handle is off by 4. Remove the addition of 4 to the maximum number of MSRs that XEN_DOMCTL_{set,get}_vcpu_msrs supports, as those are already part of the array. A further adjustment could be to subtract 4 from the maximum size if the DB= EXT CPUID feature is not exposed to the guest, but guest_{rd,wr}msr() will alre= ady perform that check when fetching or loading the MSRs. The maximum array is used to indicate the caller of the buffer it needs to allocate in the get c= ase, and as an early input sanitation in the set case, using a buffer size sligh= tly lager than required is not an issue. Fixes: 86d47adcd3c4 ('x86/msr: Handle MSR_AMD64_DR{0-3}_ADDRESS_MASK in the= new MSR infrastructure') Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Jan Beulich --- I'm tempted to just get rid of nr_msrs and use ARRAY_SIZE(msrs_to_send) instead, but refrained from doing it. --- xen/arch/x86/domctl.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index f76de5be9437..37ebcb3abbc7 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -1088,10 +1088,6 @@ long arch_do_domctl( !is_pv_domain(d) ) break; =20 - /* Count maximum number of optional msrs. */ - if ( boot_cpu_has(X86_FEATURE_DBEXT) ) - nr_msrs +=3D 4; - if ( domctl->cmd =3D=3D XEN_DOMCTL_get_vcpu_msrs ) { ret =3D 0; copyback =3D true; --=20 2.46.0