From patchwork Sat May 18 11:02:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_Bene=C5=A1?= X-Patchwork-Id: 13667571 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 B616FC25B7D for ; Sat, 18 May 2024 11:02:48 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.724746.1129911 (Exim 4.92) (envelope-from ) id 1s8Hpi-0006Sk-Qw; Sat, 18 May 2024 11:02:34 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 724746.1129911; Sat, 18 May 2024 11:02:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s8Hpi-0006Sd-OA; Sat, 18 May 2024 11:02:34 +0000 Received: by outflank-mailman (input) for mailman id 724746; Sat, 18 May 2024 11:02:32 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s8Hpg-0006PW-L8 for xen-devel@lists.xenproject.org; Sat, 18 May 2024 11:02:32 +0000 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [2a00:1450:4864:20::434]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1dfccfdf-1506-11ef-b4bb-af5377834399; Sat, 18 May 2024 13:02:30 +0200 (CEST) Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-351ae94323aso759108f8f.0 for ; Sat, 18 May 2024 04:02:29 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3502b8969fbsm23777282f8f.37.2024.05.18.04.02.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 May 2024 04:02:27 -0700 (PDT) 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: 1dfccfdf-1506-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716030148; x=1716634948; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gyu7N26K83JM6reFihsC9/TI9yx+pCoPayJ3wbx78AU=; b=F6sP0e23rHsdYO0kY9SABSvwScPX0t11n6RRu6qJxZRmcou9W5PRZ/XUYz8Q+x6rqj cW+70kij1F3Wc1NWz/jwbNHwqt/ZAfAI42S3c8rUAj4te9hidu02XdqKVzneYe8I7XLm NHZgypm/dkd7DkWYies6hENXyh4kHRXFJfzoQ22k/hKRiv4K8kfQLjvX8fIee/CSAZCS sBosLzZ+W3i5seF1RY0iY0ElToxpuWlAJ3L2s1+cijFB5iXMFRQQQtp15BC6qqyNVjOs 1+HnnZTNs3Isz8VpE8X/Iv7CZt0FzTT1I5NkhvbQIcwrxCBu4CQYxbWLcXnNoECY3Al6 OF+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716030148; x=1716634948; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gyu7N26K83JM6reFihsC9/TI9yx+pCoPayJ3wbx78AU=; b=m4iBH5wPhh4n1HlOW0TS0CrvURNrsyEfF0XXz3kBlM5KPhoo89ZcTvDLp5xQTWvCNv 1eI2PSW+CCa3Y6tSzS7FRuPhIIcdp6t/isKZ3vifQcj5INEjJWu24XfjrQV9/fZ8FSWg 0SBywn3c05n+/xB4JpA5eeIENSU0YSQHgb+2E08U2+PD7wlRxtVnXeRoC2VpyD4szB4/ hJQRpsf6zqR9z/UzKJT04nqt9l/HnwvU8VlNuuljbQ9+SspUUpscFIMH5QUrEuSpIYoa TuBJmRhuqTo479lAGuhXNYpFCsqfByvHHZ1HY1htd7pM5qUX4rVMjfcI4ia/UycX/8p4 /WYA== X-Gm-Message-State: AOJu0Yz01+G6UmVULjMaOwq1dwL8lY7E9wfcpeycu8Txw11bodJDGBd3 ZRfQFQb/S1u12pHqMOSBgnI0Ldg8gTcDNDVSzJqkm2sLOFIBGJ6yP5u8G7F1 X-Google-Smtp-Source: AGHT+IGe35sLDZcm+WO6wUrfzATgQqu1v8ygaKKDXUdhBEi8r8o+WYGxnnwQfFBbIh2r8glPt7nrKQ== X-Received: by 2002:adf:ebc2:0:b0:34c:925e:6c2c with SMTP id ffacd0b85a97d-3504a61c6c2mr19059826f8f.6.1716030148024; Sat, 18 May 2024 04:02:28 -0700 (PDT) From: " =?utf-8?q?Petr_Bene=C5=A1?= " X-Google-Original-From: =?utf-8?q?Petr_Bene=C5=A1?= To: xen-devel@lists.xenproject.org Cc: =?utf-8?q?Petr_Bene=C5=A1?= , Jan Beulich , Andrew Cooper , George Dunlap , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH for-4.19? v4 1/6] x86/p2m: Add braces for better code clarity Date: Sat, 18 May 2024 11:02:12 +0000 Message-Id: <36d1488857a595fd6a286ab2de26cd672df3f387.1716029860.git.w1benny@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 From: Petr Beneš No functional change. Signed-off-by: Petr Beneš Reviewed-by: Stefano Stabellini Acked-by: Roger Pau Monné --- xen/arch/x86/mm/p2m.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.34.1 diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 4a4620e870..db5d9b6c2a 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -106,6 +106,7 @@ void p2m_change_entry_type_global(struct domain *d, unsigned int i; for ( i = 0; i < MAX_ALTP2M; i++ ) + { if ( d->arch.altp2m_eptp[i] != mfn_x(INVALID_MFN) ) { struct p2m_domain *altp2m = d->arch.altp2m_p2m[i]; @@ -114,6 +115,7 @@ void p2m_change_entry_type_global(struct domain *d, change_entry_type_global(altp2m, ot, nt); p2m_unlock(altp2m); } + } } p2m_unlock(hostp2m); @@ -139,6 +141,7 @@ void p2m_memory_type_changed(struct domain *d) unsigned int i; for ( i = 0; i < MAX_ALTP2M; i++ ) + { if ( d->arch.altp2m_eptp[i] != mfn_x(INVALID_MFN) ) { struct p2m_domain *altp2m = d->arch.altp2m_p2m[i]; @@ -147,6 +150,7 @@ void p2m_memory_type_changed(struct domain *d) _memory_type_changed(altp2m); p2m_unlock(altp2m); } + } } p2m_unlock(hostp2m); From patchwork Sat May 18 11:02:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_Bene=C5=A1?= X-Patchwork-Id: 13667570 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 8B40BC25B7B for ; Sat, 18 May 2024 11:02:48 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.724745.1129900 (Exim 4.92) (envelope-from ) id 1s8Hpf-0006DN-I7; Sat, 18 May 2024 11:02:31 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 724745.1129900; Sat, 18 May 2024 11:02:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s8Hpf-0006DG-FZ; Sat, 18 May 2024 11:02:31 +0000 Received: by outflank-mailman (input) for mailman id 724745; Sat, 18 May 2024 11:02:30 +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 1s8Hpe-0005yr-GJ for xen-devel@lists.xenproject.org; Sat, 18 May 2024 11:02:30 +0000 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [2a00:1450:4864:20::332]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1e8082f4-1506-11ef-909f-e314d9c70b13; Sat, 18 May 2024 13:02:29 +0200 (CEST) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4202cea9a2fso8231935e9.3 for ; Sat, 18 May 2024 04:02:29 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3502b8969fbsm23777282f8f.37.2024.05.18.04.02.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 May 2024 04:02:28 -0700 (PDT) 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: 1e8082f4-1506-11ef-909f-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716030149; x=1716634949; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aWD/Qk3szSfEZBTtbpcC8O4b8u+9LVoa4Hx6fikLkdc=; b=X1CNpWfCnOd83w1vZKQTTdRnA5VbHtPh44DRpSWomUqxOkP6m9GaKnoeMjJM6HlvfJ mYguuaMxW5YyimRPhjvc/dN/esu7PlRLPyKxKO2Aom3ys2jTpsMYXMBBfJKF8f+hZn05 +4QtZEpKYOfgnKPhFZch8ZiwSSlE70Ddm98W5HvRvbY76nNyV3qn2e53u+MxYf7nYt85 3mxyhiwBeoTGywZMSHGnEGczNR7ZOq7CRMem6hVQmyBwbSoi+xYnfNZiSeCs8lFBKEF9 TkafBtJHWM1sWAwON+ml5oiRG0g4mcNIH66SlD6Vtm6xOWwJ/Ntbju3ZzvFaHjFGTQlL LiKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716030149; x=1716634949; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aWD/Qk3szSfEZBTtbpcC8O4b8u+9LVoa4Hx6fikLkdc=; b=xUzQNnFpdMLzkOtbrj0LZv3+qhCAo1NhKWv0eLXmCvp2cPBpbGJhmXBiHMNQ3totdO EMJJ48pvM+L9GiU0yaZdK3GZ3k/L2d9nnkSVtyzUKZQJbTyjunTTNs7QBYWOSyS7vLGm sezK+0FoSVtAtAKiAiOJ4Hm0sk9heS2iqMQVZchnX3su70xpqSs3sg6M6xv36P4HJYfe Y0Xb7s5qhTXDtuf5HCYnc1v9p8PzN1+rtWOUxH6J0gmi3mAohXA1QZHKVT68YcA57Rlv 5MJLGUjAwNtlymwl6AfurJazzFf9usm+SPACsN9sM+faf1vE9c8IQ+GARiFbGoxnWwoP CT7w== X-Gm-Message-State: AOJu0YycUp0AUrVESppsweA41gtTCLdAkj82MAMRj8TrygI0g81azs+X tJ2W3gujR+bDLcVWZ+/keSIgG+18H3yPHaNdTOhMj2KyUWWAcxDSHjI3WQ== X-Google-Smtp-Source: AGHT+IG7398q/5Qx6x7u3mnCKt2quXYSkSeMQG8C4wVwNPsRYjrqo+PixDsdfPG9NxBEx+6TwAKxZw== X-Received: by 2002:a5d:53c5:0:b0:34d:a29c:b8b6 with SMTP id ffacd0b85a97d-3504a6311f6mr16471163f8f.24.1716030149141; Sat, 18 May 2024 04:02:29 -0700 (PDT) From: " =?utf-8?q?Petr_Bene=C5=A1?= " X-Google-Original-From: =?utf-8?q?Petr_Bene=C5=A1?= To: xen-devel@lists.xenproject.org Cc: =?utf-8?q?Petr_Bene=C5=A1?= , George Dunlap , Nick Rosbrook , Anthony PERARD , Juergen Gross Subject: [PATCH for-4.19? v4 2/6] tools/xl: Add altp2m_count parameter Date: Sat, 18 May 2024 11:02:13 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 From: Petr Beneš Introduce a new altp2m_count parameter to control the maximum number of altp2m views a domain can use. By default, if altp2m_count is unspecified and altp2m is enabled, the value is set to 10, reflecting the legacy behavior. This change is preparatory; it establishes the groundwork for the feature but does not activate it. Signed-off-by: Petr Beneš --- tools/golang/xenlight/helpers.gen.go | 2 ++ tools/golang/xenlight/types.gen.go | 1 + tools/include/libxl.h | 8 ++++++++ tools/libs/light/libxl_create.c | 9 +++++++++ tools/libs/light/libxl_types.idl | 1 + tools/xl/xl_parse.c | 4 ++++ 6 files changed, 25 insertions(+) -- 2.34.1 diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/helpers.gen.go index 78bdb08b15..40c247a0d0 100644 --- a/tools/golang/xenlight/helpers.gen.go +++ b/tools/golang/xenlight/helpers.gen.go @@ -1158,6 +1158,7 @@ if err := x.ArchX86.MsrRelaxed.fromC(&xc.arch_x86.msr_relaxed);err != nil { return fmt.Errorf("converting field ArchX86.MsrRelaxed: %v", err) } x.Altp2M = Altp2MMode(xc.altp2m) +x.Altp2MCount = uint32(xc.altp2m_count) x.VmtraceBufKb = int(xc.vmtrace_buf_kb) if err := x.Vpmu.fromC(&xc.vpmu);err != nil { return fmt.Errorf("converting field Vpmu: %v", err) @@ -1674,6 +1675,7 @@ if err := x.ArchX86.MsrRelaxed.toC(&xc.arch_x86.msr_relaxed); err != nil { return fmt.Errorf("converting field ArchX86.MsrRelaxed: %v", err) } xc.altp2m = C.libxl_altp2m_mode(x.Altp2M) +xc.altp2m_count = C.uint32_t(x.Altp2MCount) xc.vmtrace_buf_kb = C.int(x.VmtraceBufKb) if err := x.Vpmu.toC(&xc.vpmu); err != nil { return fmt.Errorf("converting field Vpmu: %v", err) diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/types.gen.go index ccfe18019e..a3ae8ef35a 100644 --- a/tools/golang/xenlight/types.gen.go +++ b/tools/golang/xenlight/types.gen.go @@ -602,6 +602,7 @@ ArchX86 struct { MsrRelaxed Defbool } Altp2M Altp2MMode +Altp2MCount uint32 VmtraceBufKb int Vpmu Defbool } diff --git a/tools/include/libxl.h b/tools/include/libxl.h index 62cb07dea6..1f149a8015 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -1239,6 +1239,14 @@ typedef struct libxl__ctx libxl_ctx; */ #define LIBXL_HAVE_ALTP2M 1 +/* + * LIBXL_HAVE_ALTP2M_COUNT + * If this is defined, then libxl supports setting the maximum number of + * alternate p2m tables. + */ +#define LIBXL_HAVE_ALTP2M_COUNT 1 +#define LIBXL_ALTP2M_COUNT_DEFAULT (~(uint32_t)0) + /* * LIBXL_HAVE_REMUS * If this is defined, then libxl supports remus. diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_create.c index 41252ec553..236b8c1965 100644 --- a/tools/libs/light/libxl_create.c +++ b/tools/libs/light/libxl_create.c @@ -483,6 +483,15 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, return -ERROR_INVAL; } + if (b_info->altp2m_count == LIBXL_ALTP2M_COUNT_DEFAULT) { + if ((libxl_defbool_val(b_info->u.hvm.altp2m) || + b_info->altp2m != LIBXL_ALTP2M_MODE_DISABLED)) + /* Reflect the default legacy count */ + b_info->altp2m_count = 10; + else + b_info->altp2m_count = 0; + } + /* Assume that providing a bootloader user implies enabling restrict. */ libxl_defbool_setdefault(&b_info->bootloader_restrict, !!b_info->bootloader_user); diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_types.idl index 79e9c656cc..eb306fedf5 100644 --- a/tools/libs/light/libxl_types.idl +++ b/tools/libs/light/libxl_types.idl @@ -728,6 +728,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ # Alternate p2m is not bound to any architecture or guest type, as it is # supported by x86 HVM and ARM support is planned. ("altp2m", libxl_altp2m_mode), + ("altp2m_count", uint32, {'init_val': 'LIBXL_ALTP2M_COUNT_DEFAULT'}), # Size of preallocated vmtrace trace buffers (in KBYTES). # Use zero value to disable this feature. diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index c504ab3711..048ab6be0d 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -2063,6 +2063,10 @@ void parse_config_data(const char *config_source, } } + if (!xlu_cfg_get_long(config, "altp2m_count", &l, 1)) { + b_info->altp2m_count = l; + } + if (!xlu_cfg_get_long(config, "vmtrace_buf_kb", &l, 1) && l) { b_info->vmtrace_buf_kb = l; } From patchwork Sat May 18 11:02:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_Bene=C5=A1?= X-Patchwork-Id: 13667568 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 B612BC25B79 for ; Sat, 18 May 2024 11:02:48 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.724747.1129917 (Exim 4.92) (envelope-from ) id 1s8Hpj-0006W3-4s; Sat, 18 May 2024 11:02:35 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 724747.1129917; Sat, 18 May 2024 11:02:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s8Hpi-0006VV-V1; Sat, 18 May 2024 11:02:34 +0000 Received: by outflank-mailman (input) for mailman id 724747; Sat, 18 May 2024 11:02:33 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s8Hph-0006PW-9X for xen-devel@lists.xenproject.org; Sat, 18 May 2024 11:02:33 +0000 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [2a00:1450:4864:20::42f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1f11fff8-1506-11ef-b4bb-af5377834399; Sat, 18 May 2024 13:02:30 +0200 (CEST) Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-3504ad82a64so739484f8f.3 for ; Sat, 18 May 2024 04:02:30 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3502b8969fbsm23777282f8f.37.2024.05.18.04.02.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 May 2024 04:02:29 -0700 (PDT) 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: 1f11fff8-1506-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716030150; x=1716634950; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BlMJnuVPgAuWx5mzHbOSNLc3FPf2ltoLWAdUx3vSNgk=; b=gLTjy9Ns0nqu8PTPCDvsCJKYBBslocmjcdAYLbmwi4X7FfMVA7HDdlbZIxUU4uXKZn 6HyBJ/Po6UPTRp90DXOpQ2Qjs39sXS1bUg6pEGh71WEC7YOIJxzkgw/5yIsO2ni/K9Hf pzf8SQ7fXHm5xtpf1T1mwjhozvhaKj2Q98frzIS+oh2L20tBge0mMJ0Iyxf0Us1bu7Ht JSFVSAVodCNFG2Bw9NfgEZraWxeQvqkHHVuwL9OMj25EkpBEVP95DVFJH7SE9fh3v6CB KXIWq4LrUZgQXoJzVV58QckXSMPeQ5SAZI07jTXgdcDk2MrzBB0RK3mKJfAlMPJ3zS6b kS4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716030150; x=1716634950; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BlMJnuVPgAuWx5mzHbOSNLc3FPf2ltoLWAdUx3vSNgk=; b=ozckDJzIesOTB2XymCkxnKOENn8kbXGggmvU7JdZP1GvWsf1pT45P39pZPJa7QnkEQ /7N/FCLG/+Z07ly822P/D4TCOv3bljx59y8R/WSN9b/CgThYoHwHiyLW2Gnu3V9WfmTI k43qkvx4UP9FVOzNgelQaf0Ch8YnAiq34+uR3KWhCe9+5MQGcnXpARE3lT6E1XlsDbU6 BgLDJKLDQSoigmnft4RU21/XjSVi5TQoQ6tZF0KPpSr/nPGNugSNA8AoeZjDqdyVMVwD eYlDNllO4U6g9GlzXaSBAM9XUKWOBCGYFpZjgV4x0F2AoYsFlXI8peAlWBHPfBuyThpe SGgw== X-Gm-Message-State: AOJu0YwNQv0OtF2QrsTfuYHTcYl8rIa5wPzIMG2Bp69M8ItRKLurxVEd D6nZkb2pDkmyi7ybqWufAMKbIRDAJ5XMNAxY+UlltccGPETLfk5Gavbi1w== X-Google-Smtp-Source: AGHT+IF3sugIpO35EWvY9cNYgcjkJaN2OWSjqd2R9sn79jz003ogS9QhQXo8F4pZmOtiVvARJnHCyw== X-Received: by 2002:adf:e501:0:b0:34d:9e54:11ec with SMTP id ffacd0b85a97d-3504a61d24bmr16398583f8f.5.1716030150086; Sat, 18 May 2024 04:02:30 -0700 (PDT) From: " =?utf-8?q?Petr_Bene=C5=A1?= " X-Google-Original-From: =?utf-8?q?Petr_Bene=C5=A1?= To: xen-devel@lists.xenproject.org Cc: =?utf-8?q?Petr_Bene=C5=A1?= , Anthony PERARD Subject: [PATCH for-4.19? v4 3/6] docs/man: Add altp2m_count parameter to the xl.cfg manual Date: Sat, 18 May 2024 11:02:14 +0000 Message-Id: <35afc0e34aae2672a924103f77a8fe62b791b45e.1716029860.git.w1benny@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 From: Petr Beneš Update manual pages to include detailed information about the altp2m_count configuration parameter. Signed-off-by: Petr Beneš --- docs/man/xl.cfg.5.pod.in | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- 2.34.1 diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index 8f2b375ce9..5c09610cf4 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -2039,6 +2039,20 @@ a single guest HVM domain. B: While the option "altp2mhvm" is deprecated, legacy applications for x86 systems will continue to work using it. +=item B + +Specifies the maximum number of alternate-p2m views available to the guest. +This setting is crucial in domain introspection scenarios that require +multiple physical-to-machine (p2m) memory mappings to be established +simultaneously. + +Enabling multiple p2m views may increase memory usage. It is advisable to +review and adjust the B setting as necessary to accommodate +the additional memory requirements. + +B: This option is ignored if B is disabled. The default value +is 10. + =item B Enable or disables guest access to hardware virtualisation features, From patchwork Sat May 18 11:02:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_Bene=C5=A1?= X-Patchwork-Id: 13667572 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 F13FAC25B74 for ; Sat, 18 May 2024 11:02:50 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.724749.1129941 (Exim 4.92) (envelope-from ) id 1s8Hpk-0007AY-Sr; Sat, 18 May 2024 11:02:36 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 724749.1129941; Sat, 18 May 2024 11:02:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s8Hpk-0007A6-NL; Sat, 18 May 2024 11:02:36 +0000 Received: by outflank-mailman (input) for mailman id 724749; Sat, 18 May 2024 11:02:35 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s8Hpi-0006PW-Sr for xen-devel@lists.xenproject.org; Sat, 18 May 2024 11:02:35 +0000 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [2a00:1450:4864:20::431]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 202ab4ab-1506-11ef-b4bb-af5377834399; Sat, 18 May 2024 13:02:32 +0200 (CEST) Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-34da4d6f543so985408f8f.3 for ; Sat, 18 May 2024 04:02:32 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3502b8969fbsm23777282f8f.37.2024.05.18.04.02.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 May 2024 04:02:31 -0700 (PDT) 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: 202ab4ab-1506-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716030152; x=1716634952; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Y2wCtNW3QUhP9N3J/Fy1fQGx/Dx3sFuXd5cXXTLYbzg=; b=AqrQf68aw1lqxNfWfc2vdfltk9KFoGg9aWrLRM7Jkdn//+dk0FJHe09soCc2OoZite uUu3BOtwgPPo4BGwrW7h8OVtDFGipkFT/mUVOkBhSpappHs0TwZST6l9Ng1XOHiPsyxq TTbGvzz/AGhmKMZkuVZYh5Zr6uYPLMgL3UZo4/yxaiquBYwxKerhY8d226yNxhoY2nRR SRWbtdIsWknpIVWaPnvp/7QVyIjo6vM3FZ4xvdpKSYxECTfYCjvSR00K8xvNClfVzT3S BI09bz3ZuwRTjpf87OBXFcRnzTmn0EJXZ1yQ9OYkctWmfQhpDHRGWgRakLP6KNlFd4eh EFcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716030152; x=1716634952; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Y2wCtNW3QUhP9N3J/Fy1fQGx/Dx3sFuXd5cXXTLYbzg=; b=KRlCRj7rxjQRQXynWwzhCxR7zd8XFoPoTwPe1GjI+WIQXXFSdqkw7Opf+iXkZvUXUS 48vpxVExlhXrBDQPFf4Ltnca4MGWHflWB5ZV4os3eYvbNFzA0Qiib1t2O+l0XL2nIHDR 9uBgbtb773PJH0VYZsmuMXMzUZ3UnmyRfhNS/SFC+LroLerRs6y2TuOdW5viGQQrU7+G 79zJktXtyIIi3VitcjQdjIMJj1KeJHTYsurpkL0TFp2TOHteY9KMgyQ53b3DiQ35LgEo TonME8n1Lhb17BjQfcY+T8R9zboGZj9xcFekFHdgKIMbw5326Tpku4eBfOy9w4Fd96/8 fJGw== X-Gm-Message-State: AOJu0YwdAH+Rx+CVbRamKMUnk5f4wsRoFCb8gui407NwxRUYlTscAWem zOCFQd0JB7Sk+JoDw9Ic/gNQL7OorlLaqvsDWIUTcBsLiIY66JBCLb/D0pry X-Google-Smtp-Source: AGHT+IFWsbLQJAImnuNEzei7CHLPmV4kF3inVd/ch4Ctm8/zyEUhVkbFcmFZGwMuX75ux5aE3z34Ng== X-Received: by 2002:adf:ecc9:0:b0:352:2700:3f34 with SMTP id ffacd0b85a97d-3522700401emr4171544f8f.32.1716030151388; Sat, 18 May 2024 04:02:31 -0700 (PDT) From: " =?utf-8?q?Petr_Bene=C5=A1?= " X-Google-Original-From: =?utf-8?q?Petr_Bene=C5=A1?= To: xen-devel@lists.xenproject.org Cc: =?utf-8?q?Petr_Bene=C5=A1?= , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , George Dunlap , Julien Grall , Stefano Stabellini , Tamas K Lengyel , Alexandru Isaila , Petre Pircalabu Subject: [PATCH for-4.19? v4 4/6] x86: Make the maximum number of altp2m views configurable Date: Sat, 18 May 2024 11:02:15 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 From: Petr Beneš This commit introduces the ability to configure the maximum number of altp2m views for the domain during its creation. Previously, the limits were hardcoded to a maximum of 10. This change allows for greater flexibility in environments that require more or fewer altp2m views. The maximum configurable limit for max_altp2m on x86 is now set to MAX_EPTP (512). This cap is linked to the architectural limit of the EPTP-switching VMFUNC, which supports up to 512 entries. Despite there being no inherent need for limiting max_altp2m in scenarios not utilizing VMFUNC, decoupling these components would necessitate substantial code changes. Signed-off-by: Petr Beneš --- xen/arch/x86/domain.c | 12 ++++ xen/arch/x86/hvm/hvm.c | 8 ++- xen/arch/x86/hvm/vmx/vmx.c | 2 +- xen/arch/x86/include/asm/domain.h | 7 +-- xen/arch/x86/include/asm/p2m.h | 6 +- xen/arch/x86/mm/altp2m.c | 91 +++++++++++++++++++------------ xen/arch/x86/mm/hap/hap.c | 6 +- xen/arch/x86/mm/mem_access.c | 24 ++++---- xen/arch/x86/mm/mem_sharing.c | 2 +- xen/arch/x86/mm/p2m-ept.c | 12 ++-- xen/arch/x86/mm/p2m.c | 8 +-- xen/common/domain.c | 1 + xen/include/public/domctl.h | 5 +- xen/include/xen/sched.h | 2 + 14 files changed, 116 insertions(+), 70 deletions(-) -- 2.34.1 diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 00a3aaa576..3bd18cb2d0 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -685,6 +685,18 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config) return -EINVAL; } + if ( config->nr_altp2m && !hvm_altp2m_supported() ) + { + dprintk(XENLOG_INFO, "altp2m requested but not available\n"); + return -EINVAL; + } + + if ( config->nr_altp2m > MAX_EPTP ) + { + dprintk(XENLOG_INFO, "nr_altp2m must be <= %lu\n", MAX_EPTP); + return -EINVAL; + } + if ( config->vmtrace_size ) { unsigned int size = config->vmtrace_size; diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 9594e0a5c5..77e4016bdb 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4639,6 +4639,12 @@ static int do_altp2m_op( goto out; } + if ( d->nr_altp2m == 0 ) + { + rc = -EINVAL; + goto out; + } + if ( (rc = xsm_hvm_altp2mhvm_op(XSM_OTHER, d, mode, a.cmd)) ) goto out; @@ -5228,7 +5234,7 @@ void hvm_fast_singlestep(struct vcpu *v, uint16_t p2midx) if ( !hvm_is_singlestep_supported() ) return; - if ( p2midx >= MAX_ALTP2M ) + if ( p2midx >= v->domain->nr_altp2m ) return; v->arch.hvm.single_step = true; diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 5f67a48592..76ee09b701 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -4888,7 +4888,7 @@ bool asmlinkage vmx_vmenter_helper(const struct cpu_user_regs *regs) { unsigned int i; - for ( i = 0; i < MAX_ALTP2M; ++i ) + for ( i = 0; i < currd->nr_altp2m; ++i ) { if ( currd->arch.altp2m_eptp[i] == mfn_x(INVALID_MFN) ) continue; diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/domain.h index f5daeb182b..3935328781 100644 --- a/xen/arch/x86/include/asm/domain.h +++ b/xen/arch/x86/include/asm/domain.h @@ -258,11 +258,10 @@ struct paging_vcpu { struct shadow_vcpu shadow; }; -#define MAX_NESTEDP2M 10 - -#define MAX_ALTP2M 10 /* arbitrary */ #define INVALID_ALTP2M 0xffff #define MAX_EPTP (PAGE_SIZE / sizeof(uint64_t)) +#define MAX_NESTEDP2M 10 + struct p2m_domain; struct time_scale { int shift; @@ -353,7 +352,7 @@ struct arch_domain /* altp2m: allow multiple copies of host p2m */ bool altp2m_active; - struct p2m_domain *altp2m_p2m[MAX_ALTP2M]; + struct p2m_domain **altp2m_p2m; mm_lock_t altp2m_list_lock; uint64_t *altp2m_eptp; uint64_t *altp2m_visible_eptp; diff --git a/xen/arch/x86/include/asm/p2m.h b/xen/arch/x86/include/asm/p2m.h index 111badf89a..e66c081149 100644 --- a/xen/arch/x86/include/asm/p2m.h +++ b/xen/arch/x86/include/asm/p2m.h @@ -881,7 +881,7 @@ static inline struct p2m_domain *p2m_get_altp2m(struct vcpu *v) if ( index == INVALID_ALTP2M ) return NULL; - BUG_ON(index >= MAX_ALTP2M); + BUG_ON(index >= v->domain->nr_altp2m); return v->domain->arch.altp2m_p2m[index]; } @@ -891,7 +891,7 @@ static inline bool p2m_set_altp2m(struct vcpu *v, unsigned int idx) { struct p2m_domain *orig; - BUG_ON(idx >= MAX_ALTP2M); + BUG_ON(idx >= v->domain->nr_altp2m); if ( idx == vcpu_altp2m(v).p2midx ) return false; @@ -943,7 +943,7 @@ int p2m_altp2m_propagate_change(struct domain *d, gfn_t gfn, p2m_type_t p2mt, p2m_access_t p2ma); /* Set a specific p2m view visibility */ -int p2m_set_altp2m_view_visibility(struct domain *d, unsigned int altp2m_idx, +int p2m_set_altp2m_view_visibility(struct domain *d, unsigned int idx, uint8_t visible); #else /* !CONFIG_HVM */ struct p2m_domain *p2m_get_altp2m(struct vcpu *v); diff --git a/xen/arch/x86/mm/altp2m.c b/xen/arch/x86/mm/altp2m.c index 6fe1e9ed6b..5cb71c8b8e 100644 --- a/xen/arch/x86/mm/altp2m.c +++ b/xen/arch/x86/mm/altp2m.c @@ -15,6 +15,11 @@ void altp2m_vcpu_initialise(struct vcpu *v) { + struct domain *d = v->domain; + + if ( d->nr_altp2m == 0 ) + return; + if ( v != current ) vcpu_pause(v); @@ -30,8 +35,12 @@ altp2m_vcpu_initialise(struct vcpu *v) void altp2m_vcpu_destroy(struct vcpu *v) { + struct domain *d = v->domain; struct p2m_domain *p2m; + if ( d->nr_altp2m == 0 ) + return; + if ( v != current ) vcpu_pause(v); @@ -122,7 +131,12 @@ int p2m_init_altp2m(struct domain *d) struct p2m_domain *hostp2m = p2m_get_hostp2m(d); mm_lock_init(&d->arch.altp2m_list_lock); - for ( i = 0; i < MAX_ALTP2M; i++ ) + d->arch.altp2m_p2m = xzalloc_array(struct p2m_domain *, d->nr_altp2m); + + if ( !d->arch.altp2m_p2m ) + return -ENOMEM; + + for ( i = 0; i < d->nr_altp2m; i++ ) { d->arch.altp2m_p2m[i] = p2m = p2m_init_one(d); if ( p2m == NULL ) @@ -143,7 +157,10 @@ void p2m_teardown_altp2m(struct domain *d) unsigned int i; struct p2m_domain *p2m; - for ( i = 0; i < MAX_ALTP2M; i++ ) + if ( !d->arch.altp2m_p2m ) + return; + + for ( i = 0; i < d->nr_altp2m; i++ ) { if ( !d->arch.altp2m_p2m[i] ) continue; @@ -151,6 +168,8 @@ void p2m_teardown_altp2m(struct domain *d) d->arch.altp2m_p2m[i] = NULL; p2m_free_one(p2m); } + + XFREE(d->arch.altp2m_p2m); } int altp2m_get_effective_entry(struct p2m_domain *ap2m, gfn_t gfn, mfn_t *mfn, @@ -200,7 +219,7 @@ bool p2m_switch_vcpu_altp2m_by_id(struct vcpu *v, unsigned int idx) struct domain *d = v->domain; bool rc = false; - if ( idx >= MAX_ALTP2M ) + if ( idx >= d->nr_altp2m ) return rc; altp2m_list_lock(d); @@ -306,8 +325,8 @@ static void p2m_reset_altp2m(struct domain *d, unsigned int idx, { struct p2m_domain *p2m; - ASSERT(idx < MAX_ALTP2M); - p2m = array_access_nospec(d->arch.altp2m_p2m, idx); + ASSERT(idx < d->nr_altp2m); + p2m = d->arch.altp2m_p2m[idx]; p2m_lock(p2m); @@ -332,7 +351,7 @@ void p2m_flush_altp2m(struct domain *d) altp2m_list_lock(d); - for ( i = 0; i < MAX_ALTP2M; i++ ) + for ( i = 0; i < d->nr_altp2m; i++ ) { p2m_reset_altp2m(d, i, ALTP2M_DEACTIVATE); d->arch.altp2m_eptp[i] = mfn_x(INVALID_MFN); @@ -348,9 +367,9 @@ static int p2m_activate_altp2m(struct domain *d, unsigned int idx, struct p2m_domain *hostp2m, *p2m; int rc; - ASSERT(idx < MAX_ALTP2M); + ASSERT(idx < d->nr_altp2m); - p2m = array_access_nospec(d->arch.altp2m_p2m, idx); + p2m = d->arch.altp2m_p2m[idx]; hostp2m = p2m_get_hostp2m(d); p2m_lock(p2m); @@ -388,12 +407,12 @@ int p2m_init_altp2m_by_id(struct domain *d, unsigned int idx) int rc = -EINVAL; struct p2m_domain *hostp2m = p2m_get_hostp2m(d); - if ( idx >= min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) ) + if ( idx >= d->nr_altp2m ) return rc; altp2m_list_lock(d); - if ( d->arch.altp2m_eptp[array_index_nospec(idx, MAX_EPTP)] == + if ( d->arch.altp2m_eptp[array_index_nospec(idx, d->nr_altp2m)] == mfn_x(INVALID_MFN) ) rc = p2m_activate_altp2m(d, idx, hostp2m->default_access); @@ -415,7 +434,7 @@ int p2m_init_next_altp2m(struct domain *d, uint16_t *idx, altp2m_list_lock(d); - for ( i = 0; i < MAX_ALTP2M; i++ ) + for ( i = 0; i < d->nr_altp2m; i++ ) { if ( d->arch.altp2m_eptp[i] != mfn_x(INVALID_MFN) ) continue; @@ -437,7 +456,7 @@ int p2m_destroy_altp2m_by_id(struct domain *d, unsigned int idx) struct p2m_domain *p2m; int rc = -EBUSY; - if ( !idx || idx >= min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) ) + if ( !idx || idx >= d->nr_altp2m ) return rc; rc = domain_pause_except_self(d); @@ -447,17 +466,17 @@ int p2m_destroy_altp2m_by_id(struct domain *d, unsigned int idx) rc = -EBUSY; altp2m_list_lock(d); - if ( d->arch.altp2m_eptp[array_index_nospec(idx, MAX_EPTP)] != + if ( d->arch.altp2m_eptp[array_index_nospec(idx, d->nr_altp2m)] != mfn_x(INVALID_MFN) ) { - p2m = array_access_nospec(d->arch.altp2m_p2m, idx); + p2m = d->arch.altp2m_p2m[array_index_nospec(idx, d->nr_altp2m)]; if ( !_atomic_read(p2m->active_vcpus) ) { p2m_reset_altp2m(d, idx, ALTP2M_DEACTIVATE); - d->arch.altp2m_eptp[array_index_nospec(idx, MAX_EPTP)] = + d->arch.altp2m_eptp[array_index_nospec(idx, d->nr_altp2m)] = mfn_x(INVALID_MFN); - d->arch.altp2m_visible_eptp[array_index_nospec(idx, MAX_EPTP)] = + d->arch.altp2m_visible_eptp[array_index_nospec(idx, d->nr_altp2m)] = mfn_x(INVALID_MFN); rc = 0; } @@ -475,7 +494,7 @@ int p2m_switch_domain_altp2m_by_id(struct domain *d, unsigned int idx) struct vcpu *v; int rc = -EINVAL; - if ( idx >= MAX_ALTP2M ) + if ( idx >= d->nr_altp2m ) return rc; rc = domain_pause_except_self(d); @@ -510,13 +529,13 @@ int p2m_change_altp2m_gfn(struct domain *d, unsigned int idx, mfn_t mfn; int rc = -EINVAL; - if ( idx >= min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) || - d->arch.altp2m_eptp[array_index_nospec(idx, MAX_EPTP)] == + if ( idx >= d->nr_altp2m || + d->arch.altp2m_eptp[array_index_nospec(idx, d->nr_altp2m)] == mfn_x(INVALID_MFN) ) return rc; hp2m = p2m_get_hostp2m(d); - ap2m = array_access_nospec(d->arch.altp2m_p2m, idx); + ap2m = d->arch.altp2m_p2m[array_index_nospec(idx, d->nr_altp2m)]; p2m_lock(hp2m); p2m_lock(ap2m); @@ -572,7 +591,7 @@ int p2m_altp2m_propagate_change(struct domain *d, gfn_t gfn, altp2m_list_lock(d); - for ( i = 0; i < MAX_ALTP2M; i++ ) + for ( i = 0; i < d->nr_altp2m; i++ ) { p2m_type_t t; p2m_access_t a; @@ -595,7 +614,7 @@ int p2m_altp2m_propagate_change(struct domain *d, gfn_t gfn, else { /* At least 2 altp2m's impacted, so reset everything */ - for ( i = 0; i < MAX_ALTP2M; i++ ) + for ( i = 0; i < d->nr_altp2m; i++ ) { if ( i == last_reset_idx || d->arch.altp2m_eptp[i] == mfn_x(INVALID_MFN) ) @@ -659,12 +678,13 @@ int p2m_set_suppress_ve_multi(struct domain *d, if ( sve->view > 0 ) { - if ( sve->view >= min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) || - d->arch.altp2m_eptp[array_index_nospec(sve->view, MAX_EPTP)] == + if ( sve->view >= d->nr_altp2m || + d->arch.altp2m_eptp[array_index_nospec(sve->view, d->nr_altp2m)] == mfn_x(INVALID_MFN) ) return -EINVAL; - p2m = ap2m = array_access_nospec(d->arch.altp2m_p2m, sve->view); + p2m = ap2m = + d->arch.altp2m_p2m[array_index_nospec(sve->view, d->nr_altp2m)]; } p2m_lock(host_p2m); @@ -727,12 +747,13 @@ int p2m_get_suppress_ve(struct domain *d, gfn_t gfn, bool *suppress_ve, if ( altp2m_idx > 0 ) { - if ( altp2m_idx >= min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) || - d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)] == + if ( altp2m_idx >= d->nr_altp2m || + d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, d->nr_altp2m)] == mfn_x(INVALID_MFN) ) return -EINVAL; - p2m = ap2m = array_access_nospec(d->arch.altp2m_p2m, altp2m_idx); + p2m = ap2m = + d->arch.altp2m_p2m[array_index_nospec(altp2m_idx, d->nr_altp2m)]; } else p2m = host_p2m; @@ -754,7 +775,7 @@ int p2m_get_suppress_ve(struct domain *d, gfn_t gfn, bool *suppress_ve, return rc; } -int p2m_set_altp2m_view_visibility(struct domain *d, unsigned int altp2m_idx, +int p2m_set_altp2m_view_visibility(struct domain *d, unsigned int idx, uint8_t visible) { int rc = 0; @@ -763,17 +784,17 @@ int p2m_set_altp2m_view_visibility(struct domain *d, unsigned int altp2m_idx, /* * Eptp index is correlated with altp2m index and should not exceed - * min(MAX_ALTP2M, MAX_EPTP). + * d->nr_altp2m. */ - if ( altp2m_idx >= min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) || - d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)] == + if ( idx >= d->nr_altp2m || + d->arch.altp2m_eptp[array_index_nospec(idx, d->nr_altp2m)] == mfn_x(INVALID_MFN) ) rc = -EINVAL; else if ( visible ) - d->arch.altp2m_visible_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)] = - d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)]; + d->arch.altp2m_visible_eptp[array_index_nospec(idx, d->nr_altp2m)] = + d->arch.altp2m_eptp[array_index_nospec(idx, d->nr_altp2m)]; else - d->arch.altp2m_visible_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)] = + d->arch.altp2m_visible_eptp[array_index_nospec(idx, d->nr_altp2m)] = mfn_x(INVALID_MFN); altp2m_list_unlock(d); diff --git a/xen/arch/x86/mm/hap/hap.c b/xen/arch/x86/mm/hap/hap.c index d2011fde24..501fd9848b 100644 --- a/xen/arch/x86/mm/hap/hap.c +++ b/xen/arch/x86/mm/hap/hap.c @@ -515,7 +515,7 @@ int hap_enable(struct domain *d, u32 mode) d->arch.altp2m_visible_eptp[i] = mfn_x(INVALID_MFN); } - for ( i = 0; i < MAX_ALTP2M; i++ ) + for ( i = 0; i < d->nr_altp2m; i++ ) { rv = p2m_alloc_table(d->arch.altp2m_p2m[i]); if ( rv != 0 ) @@ -538,7 +538,7 @@ void hap_final_teardown(struct domain *d) unsigned int i; if ( hvm_altp2m_supported() ) - for ( i = 0; i < MAX_ALTP2M; i++ ) + for ( i = 0; i < d->nr_altp2m; i++ ) p2m_teardown(d->arch.altp2m_p2m[i], true, NULL); /* Destroy nestedp2m's first */ @@ -590,7 +590,7 @@ void hap_teardown(struct domain *d, bool *preempted) FREE_XENHEAP_PAGE(d->arch.altp2m_eptp); FREE_XENHEAP_PAGE(d->arch.altp2m_visible_eptp); - for ( i = 0; i < MAX_ALTP2M; i++ ) + for ( i = 0; i < d->nr_altp2m; i++ ) { p2m_teardown(d->arch.altp2m_p2m[i], false, preempted); if ( preempted && *preempted ) diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c index 60a0cce68a..63bb2e10ed 100644 --- a/xen/arch/x86/mm/mem_access.c +++ b/xen/arch/x86/mm/mem_access.c @@ -347,12 +347,12 @@ long p2m_set_mem_access(struct domain *d, gfn_t gfn, uint32_t nr, /* altp2m view 0 is treated as the hostp2m */ if ( altp2m_idx ) { - if ( altp2m_idx >= min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) || - d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)] == + if ( altp2m_idx >= d->nr_altp2m || + d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, d->nr_altp2m)] == mfn_x(INVALID_MFN) ) return -EINVAL; - ap2m = array_access_nospec(d->arch.altp2m_p2m, altp2m_idx); + ap2m = d->arch.altp2m_p2m[array_index_nospec(altp2m_idx, d->nr_altp2m)]; } if ( !xenmem_access_to_p2m_access(p2m, access, &a) ) @@ -403,12 +403,12 @@ long p2m_set_mem_access_multi(struct domain *d, /* altp2m view 0 is treated as the hostp2m */ if ( altp2m_idx ) { - if ( altp2m_idx >= min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) || - d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)] == - mfn_x(INVALID_MFN) ) + if ( altp2m_idx >= d->nr_altp2m || + d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, d->nr_altp2m)] + == mfn_x(INVALID_MFN) ) return -EINVAL; - ap2m = array_access_nospec(d->arch.altp2m_p2m, altp2m_idx); + ap2m = d->arch.altp2m_p2m[array_index_nospec(altp2m_idx, d->nr_altp2m)]; } p2m_lock(p2m); @@ -466,12 +466,12 @@ int p2m_get_mem_access(struct domain *d, gfn_t gfn, xenmem_access_t *access, } else if ( altp2m_idx ) /* altp2m view 0 is treated as the hostp2m */ { - if ( altp2m_idx >= min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) || - d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)] == - mfn_x(INVALID_MFN) ) + if ( altp2m_idx >= d->nr_altp2m || + d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, d->nr_altp2m)] + == mfn_x(INVALID_MFN) ) return -EINVAL; - p2m = array_access_nospec(d->arch.altp2m_p2m, altp2m_idx); + p2m = d->arch.altp2m_p2m[array_index_nospec(altp2m_idx, d->nr_altp2m)]; } return _p2m_get_mem_access(p2m, gfn, access); @@ -486,7 +486,7 @@ void arch_p2m_set_access_required(struct domain *d, bool access_required) if ( altp2m_active(d) ) { unsigned int i; - for ( i = 0; i < MAX_ALTP2M; i++ ) + for ( i = 0; i < d->nr_altp2m; i++ ) { struct p2m_domain *p2m = d->arch.altp2m_p2m[i]; diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c index da28266ef0..83bb9dd5df 100644 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -912,7 +912,7 @@ static int nominate_page(struct domain *d, gfn_t gfn, altp2m_list_lock(d); - for ( i = 0; i < MAX_ALTP2M; i++ ) + for ( i = 0; i < d->nr_altp2m; i++ ) { ap2m = d->arch.altp2m_p2m[i]; if ( !ap2m ) diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index f83610cb8c..42b868ca45 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -1293,7 +1293,7 @@ static void ept_set_ad_sync(struct domain *d, bool value) { unsigned int i; - for ( i = 0; i < MAX_ALTP2M; i++ ) + for ( i = 0; i < d->nr_altp2m; i++ ) { struct p2m_domain *p2m; @@ -1500,15 +1500,17 @@ void setup_ept_dump(void) void p2m_init_altp2m_ept(struct domain *d, unsigned int i) { - struct p2m_domain *p2m = array_access_nospec(d->arch.altp2m_p2m, i); + struct p2m_domain *p2m = + d->arch.altp2m_p2m[array_index_nospec(i, d->nr_altp2m)]; struct p2m_domain *hostp2m = p2m_get_hostp2m(d); struct ept_data *ept; p2m->ept.ad = hostp2m->ept.ad; ept = &p2m->ept; ept->mfn = pagetable_get_pfn(p2m_get_pagetable(p2m)); - d->arch.altp2m_eptp[array_index_nospec(i, MAX_EPTP)] = ept->eptp; - d->arch.altp2m_visible_eptp[array_index_nospec(i, MAX_EPTP)] = ept->eptp; + d->arch.altp2m_eptp[array_index_nospec(i, d->nr_altp2m)] = ept->eptp; + d->arch.altp2m_visible_eptp[array_index_nospec(i, d->nr_altp2m)] = + ept->eptp; } unsigned int p2m_find_altp2m_by_eptp(struct domain *d, uint64_t eptp) @@ -1519,7 +1521,7 @@ unsigned int p2m_find_altp2m_by_eptp(struct domain *d, uint64_t eptp) altp2m_list_lock(d); - for ( i = 0; i < MAX_ALTP2M; i++ ) + for ( i = 0; i < d->nr_altp2m; i++ ) { if ( d->arch.altp2m_eptp[i] == mfn_x(INVALID_MFN) ) continue; diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index db5d9b6c2a..549aec8d6b 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -105,7 +105,7 @@ void p2m_change_entry_type_global(struct domain *d, { unsigned int i; - for ( i = 0; i < MAX_ALTP2M; i++ ) + for ( i = 0; i < d->nr_altp2m; i++ ) { if ( d->arch.altp2m_eptp[i] != mfn_x(INVALID_MFN) ) { @@ -140,7 +140,7 @@ void p2m_memory_type_changed(struct domain *d) { unsigned int i; - for ( i = 0; i < MAX_ALTP2M; i++ ) + for ( i = 0; i < d->nr_altp2m; i++ ) { if ( d->arch.altp2m_eptp[i] != mfn_x(INVALID_MFN) ) { @@ -913,7 +913,7 @@ void p2m_change_type_range(struct domain *d, { unsigned int i; - for ( i = 0; i < MAX_ALTP2M; i++ ) + for ( i = 0; i < d->nr_altp2m; i++ ) { if ( d->arch.altp2m_eptp[i] != mfn_x(INVALID_MFN) ) { @@ -986,7 +986,7 @@ int p2m_finish_type_change(struct domain *d, { unsigned int i; - for ( i = 0; i < MAX_ALTP2M; i++ ) + for ( i = 0; i < d->nr_altp2m; i++ ) { if ( d->arch.altp2m_eptp[i] != mfn_x(INVALID_MFN) ) { diff --git a/xen/common/domain.c b/xen/common/domain.c index 6773f7fb90..a10a70e9d4 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -610,6 +610,7 @@ struct domain *domain_create(domid_t domid, if ( config ) { d->options = config->flags; + d->nr_altp2m = config->nr_altp2m; d->vmtrace_size = config->vmtrace_size; } diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index a33f9ec32b..60a871f123 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -21,7 +21,7 @@ #include "hvm/save.h" #include "memory.h" -#define XEN_DOMCTL_INTERFACE_VERSION 0x00000016 +#define XEN_DOMCTL_INTERFACE_VERSION 0x00000017 /* * NB. xen_domctl.domain is an IN/OUT parameter for this operation. @@ -86,6 +86,9 @@ struct xen_domctl_createdomain { uint32_t grant_opts; + /* Number of altp2ms to allocate. */ + uint32_t nr_altp2m; + /* Per-vCPU buffer size in bytes. 0 to disable. */ uint32_t vmtrace_size; diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 132b841995..18cc0748a1 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -602,6 +602,8 @@ struct domain unsigned int guest_request_sync : 1; } monitor; + unsigned int nr_altp2m; /* Number of altp2m tables */ + unsigned int vmtrace_size; /* Buffer size in bytes, or 0 to disable. */ #ifdef CONFIG_ARGO From patchwork Sat May 18 11:02:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_Bene=C5=A1?= X-Patchwork-Id: 13667569 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 EA7B9C25B7A for ; Sat, 18 May 2024 11:02:47 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.724748.1129922 (Exim 4.92) (envelope-from ) id 1s8Hpj-0006g6-I7; Sat, 18 May 2024 11:02:35 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 724748.1129922; Sat, 18 May 2024 11:02:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s8Hpj-0006cP-Cr; Sat, 18 May 2024 11:02:35 +0000 Received: by outflank-mailman (input) for mailman id 724748; Sat, 18 May 2024 11:02:33 +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 1s8Hph-0005yr-ML for xen-devel@lists.xenproject.org; Sat, 18 May 2024 11:02:33 +0000 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [2a00:1450:4864:20::335]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2074f509-1506-11ef-909f-e314d9c70b13; Sat, 18 May 2024 13:02:33 +0200 (CEST) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4202959b060so8032425e9.2 for ; Sat, 18 May 2024 04:02:33 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3502b8969fbsm23777282f8f.37.2024.05.18.04.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 May 2024 04:02:32 -0700 (PDT) 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: 2074f509-1506-11ef-909f-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716030152; x=1716634952; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lcXsJFjS9m5+2bzRAoHvtJjIOqkMU5GtwndPgJCwhX4=; b=GudoogxHMvdn4w0cqD5eTYm6th1gwGqv4gs9gLQ0mrO/5R7z0FK1O8tgF9pLN2rqYY 1foSI5c7Su2FqiCj7Ee0xeV76j0alPFhUQS5em1KWrXTjPQBYtet64ycX1U3KiSDpSMQ wx4zEUAQSLvTlPSniIpfmTMAmyptDslAAMd+zqdyFkpMYkU8orb5jDGpxZaiEd/IKzzu zSdrX8n+I//YEa5P4GsdX20ZzQXaIbUGPzjjgTqYHlZRxavOHzLNX2PiLdafsRnsNkGr lRTIHsgj2WhZChYNvB1iQgzK15G5Qw3SSsIxsFc81ai6ps7d5SMyV3LzaLagSuzHixQk LWlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716030152; x=1716634952; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lcXsJFjS9m5+2bzRAoHvtJjIOqkMU5GtwndPgJCwhX4=; b=K+KBs7P3a2cOK3dwrgqjZTICWF5x2Wn5XSy0Wz2iutxak8D6ag18c2cGv2ugsja3VU 26303llDZR2kjrhaPKCBDpDH84MogP3jqRHx2GSjYcUzJtu4SwNBsYmg9SYtJVTHpoma wMK7jMCqXzbVr1mbnyeHT8u/dgPSf/pzFTtMdf6ADVur15QZeF3QG1d2j2l9O5vRZd9d A5HmLlWHKsEc+jbbj6aHHXQqgVV9UtMuTVrOKsAwp0uVPM2D2nNw3GkAn5rJ80JuRvJn TAqKQ9ILhg4iAtH60P0CC7W1mfnKItkZdB/sfj0TL/v3ADT70J1q0asJz8as2eKhbZu7 Cctw== X-Gm-Message-State: AOJu0Yxh1unlnQGp9pTxbTZB2ebDkTBYbkuTEZbzUjLxKkkIp1p5tZND xaZ5Ivs8ip8A7sq4lqn15X0bvP57bNS5QZc7ZZO1g0KDlZ9K9sIQNoESXA== X-Google-Smtp-Source: AGHT+IECOdi8/7PFZQliYUQDOmQMOAewH/Lgc3HHGhX0HkDS8B59my93i6l669Pnaf3F5kA5yxREEQ== X-Received: by 2002:a05:600c:1f92:b0:420:29dd:84dd with SMTP id 5b1f17b1804b1-42029dd8865mr50068795e9.3.1716030152348; Sat, 18 May 2024 04:02:32 -0700 (PDT) From: " =?utf-8?q?Petr_Bene=C5=A1?= " X-Google-Original-From: =?utf-8?q?Petr_Bene=C5=A1?= To: xen-devel@lists.xenproject.org Cc: =?utf-8?q?Petr_Bene=C5=A1?= , Anthony PERARD , Juergen Gross Subject: [PATCH for-4.19? v4 5/6] tools/libxl: Activate the altp2m_count feature Date: Sat, 18 May 2024 11:02:16 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 From: Petr Beneš This commit activates the previously introduced altp2m_count parameter, establishing the connection between libxl and Xen. Signed-off-by: Petr Beneš --- tools/libs/light/libxl_create.c | 1 + 1 file changed, 1 insertion(+) -- 2.34.1 diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_create.c index 236b8c1965..f5eb16d0dc 100644 --- a/tools/libs/light/libxl_create.c +++ b/tools/libs/light/libxl_create.c @@ -657,6 +657,7 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config, .max_grant_frames = b_info->max_grant_frames, .max_maptrack_frames = b_info->max_maptrack_frames, .grant_opts = XEN_DOMCTL_GRANT_version(b_info->max_grant_version), + .nr_altp2m = b_info->altp2m_count, .vmtrace_size = ROUNDUP(b_info->vmtrace_buf_kb << 10, XC_PAGE_SHIFT), .cpupool_id = info->poolid, }; From patchwork Sat May 18 11:02:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_Bene=C5=A1?= X-Patchwork-Id: 13667566 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 D1308C25B74 for ; Sat, 18 May 2024 11:02:47 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.724750.1129947 (Exim 4.92) (envelope-from ) id 1s8Hpl-0007Jj-Fo; Sat, 18 May 2024 11:02:37 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 724750.1129947; Sat, 18 May 2024 11:02:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s8Hpl-0007Ha-8C; Sat, 18 May 2024 11:02:37 +0000 Received: by outflank-mailman (input) for mailman id 724750; Sat, 18 May 2024 11:02:35 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s8Hpj-0006PW-SN for xen-devel@lists.xenproject.org; Sat, 18 May 2024 11:02:35 +0000 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [2a00:1450:4864:20::32b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2123da9d-1506-11ef-b4bb-af5377834399; Sat, 18 May 2024 13:02:34 +0200 (CEST) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-420104e5336so5201145e9.1 for ; Sat, 18 May 2024 04:02:34 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3502b8969fbsm23777282f8f.37.2024.05.18.04.02.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 May 2024 04:02:33 -0700 (PDT) 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: 2123da9d-1506-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716030153; x=1716634953; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CZx7e4I8f24AmBOZ73vCNLclq5iufdJNqbBIJFjDxwY=; b=MpZ2gj2nWq0O6DAu4jX0D5Y2ONcuKIHJdvbOoT7OAR1FtOgqJt1rYjzi4B3Xqc1yB6 ayubHyvZbJUdFQQPzTw/sR63pwdz5S1tpSycvgknGIxgw6rCAOZnOy6PTyAbCEQKFiOn RvRIpzI0D+kJc8dkgphYfHnNDCr+q3fh0ss7xfFFrIHsJOY1AUXwQdF2V0wRebyg1Bdw E4CQANVArrsgkXGAEFKrnU/E4W7DuwmkpovyydON0PlN9QIrLqi2e2ktOlMvvMuaY3M4 q0FKQ3Xq7uMGjr2fAsreOGP5HIEQZmUToHmbxCRVVh577rY9zN1VSd1u3dJ203opbUgH Z3qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716030153; x=1716634953; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CZx7e4I8f24AmBOZ73vCNLclq5iufdJNqbBIJFjDxwY=; b=PiW1AkU29a61ho/LQ9a5mH/hC7oS3o5k24vTM9LoE4HWVGZmUMC0Ld8JfVA0TYi8Hp G9iDGZJncF74fvaiZqwaa4lCWbS8FIDqENvs5eEnYk0Bhiozc5ZKf3u0MlYemcgt5hfJ LhtvOgKbYdGAa/3PiBplHLWy48Kw/gMeQCY0kUw9ln/QvN7ju1Wm76gJMCaC3Js2dAq/ +iSpEjVuKguruy3XhToEGUhN30QiUp/9b/T1eFA8QYA4njuNQxuCclyQhk/ZiLFfbP4G n/da1g6BuWpeIzOsExw/3hldI6zHipUbXYxjRJ8YmjR0BBb6sVxYcz4V30FAFmBA8tm5 xWpA== X-Gm-Message-State: AOJu0Yx1FUbQKrlPt60U0/qi9KXLwvyrvu8NkWtpEXiuEQP8NiJas2tf EhQ/BdwOBaYIdPMPOqXFMTTaHDLt+zZ/FZGkAKMHqU37F41pgzR+5n8Hfw== X-Google-Smtp-Source: AGHT+IHsRTfJKAJsoyxs2Lhvbc+XDn+/W7DQC6ZXTI8u/8PQVwkGsEuGgUjdy6Bw0awD8RmAgnXg6w== X-Received: by 2002:a05:600c:1c16:b0:418:bdcd:e59b with SMTP id 5b1f17b1804b1-420e19d5fa3mr13856515e9.7.1716030153510; Sat, 18 May 2024 04:02:33 -0700 (PDT) From: " =?utf-8?q?Petr_Bene=C5=A1?= " X-Google-Original-From: =?utf-8?q?Petr_Bene=C5=A1?= To: xen-devel@lists.xenproject.org Cc: =?utf-8?q?Petr_Bene=C5=A1?= , Christian Lindig , David Scott , Anthony PERARD , Christian Lindig Subject: [PATCH for-4.19? v4 6/6] tools/ocaml: Add altp2m_count parameter Date: Sat, 18 May 2024 11:02:17 +0000 Message-Id: <9ae1893beea2bb043413c014bd4adf6cbdab0aa7.1716029860.git.w1benny@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 From: Petr Beneš Allow developers using the OCaml bindings to set the altp2m_count parameter. Signed-off-by: Petr Beneš Acked-by: Christian Lindig --- tools/ocaml/libs/xc/xenctrl.ml | 1 + tools/ocaml/libs/xc/xenctrl.mli | 1 + tools/ocaml/libs/xc/xenctrl_stubs.c | 11 +++++++---- 3 files changed, 9 insertions(+), 4 deletions(-) -- 2.34.1 diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml index 55923857ec..dfb3d331c9 100644 --- a/tools/ocaml/libs/xc/xenctrl.ml +++ b/tools/ocaml/libs/xc/xenctrl.ml @@ -85,6 +85,7 @@ type domctl_create_config = max_grant_frames: int; max_maptrack_frames: int; max_grant_version: int; + altp2m_count: int; vmtrace_buf_kb: int32; cpupool_id: int32; arch: arch_domainconfig; diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.mli index 9b4b45db3a..ff0e309c56 100644 --- a/tools/ocaml/libs/xc/xenctrl.mli +++ b/tools/ocaml/libs/xc/xenctrl.mli @@ -77,6 +77,7 @@ type domctl_create_config = { max_grant_frames: int; max_maptrack_frames: int; max_grant_version: int; + altp2m_count: int; vmtrace_buf_kb: int32; cpupool_id: int32; arch: arch_domainconfig; diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenctrl_stubs.c index 2b6d3c09df..1f544cd2e4 100644 --- a/tools/ocaml/libs/xc/xenctrl_stubs.c +++ b/tools/ocaml/libs/xc/xenctrl_stubs.c @@ -210,9 +210,10 @@ CAMLprim value stub_xc_domain_create(value xch_val, value wanted_domid, value co #define VAL_MAX_GRANT_FRAMES Field(config, 6) #define VAL_MAX_MAPTRACK_FRAMES Field(config, 7) #define VAL_MAX_GRANT_VERSION Field(config, 8) -#define VAL_VMTRACE_BUF_KB Field(config, 9) -#define VAL_CPUPOOL_ID Field(config, 10) -#define VAL_ARCH Field(config, 11) +#define VAL_ALTP2M_COUNT Field(config, 9) +#define VAL_VMTRACE_BUF_KB Field(config, 10) +#define VAL_CPUPOOL_ID Field(config, 11) +#define VAL_ARCH Field(config, 12) uint32_t domid = Int_val(wanted_domid); uint64_t vmtrace_size = Int32_val(VAL_VMTRACE_BUF_KB); @@ -230,6 +231,7 @@ CAMLprim value stub_xc_domain_create(value xch_val, value wanted_domid, value co .max_maptrack_frames = Int_val(VAL_MAX_MAPTRACK_FRAMES), .grant_opts = XEN_DOMCTL_GRANT_version(Int_val(VAL_MAX_GRANT_VERSION)), + .nr_altp2m = Int_val(VAL_ALTP2M_COUNT), .vmtrace_size = vmtrace_size, .cpupool_id = Int32_val(VAL_CPUPOOL_ID), }; @@ -257,7 +259,7 @@ CAMLprim value stub_xc_domain_create(value xch_val, value wanted_domid, value co #if defined(__i386__) || defined(__x86_64__) /* Quick & dirty check for ABI changes. */ - BUILD_BUG_ON(sizeof(cfg) != 64); + BUILD_BUG_ON(sizeof(cfg) != 68); /* Mnemonics for the named fields inside xen_x86_arch_domainconfig */ #define VAL_EMUL_FLAGS Field(arch_domconfig, 0) @@ -288,6 +290,7 @@ CAMLprim value stub_xc_domain_create(value xch_val, value wanted_domid, value co #undef VAL_ARCH #undef VAL_CPUPOOL_ID #undef VAL_VMTRACE_BUF_KB +#undef VAL_ALTP2M_COUNT #undef VAL_MAX_GRANT_VERSION #undef VAL_MAX_MAPTRACK_FRAMES #undef VAL_MAX_GRANT_FRAMES