From patchwork Sun Apr 28 16:52:36 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: 13646074 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 6B1ADC4345F for ; Sun, 28 Apr 2024 16:53:12 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.713703.1114594 (Exim 4.92) (envelope-from ) id 1s17lo-0006T6-Fn; Sun, 28 Apr 2024 16:52:56 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 713703.1114594; Sun, 28 Apr 2024 16:52:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s17lo-0006Sz-BE; Sun, 28 Apr 2024 16:52:56 +0000 Received: by outflank-mailman (input) for mailman id 713703; Sun, 28 Apr 2024 16:52:52 +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 1s17lk-0006D5-Gg for xen-devel@lists.xenproject.org; Sun, 28 Apr 2024 16:52:52 +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 bf97f75c-057f-11ef-b4bb-af5377834399; Sun, 28 Apr 2024 18:52:50 +0200 (CEST) Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-346359c8785so3287017f8f.0 for ; Sun, 28 Apr 2024 09:52:50 -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 a12-20020a056000188c00b00347eb354b30sm27850921wri.84.2024.04.28.09.52.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 09:52:49 -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: bf97f75c-057f-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714323170; x=1714927970; 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=bNif3eZYUBF7BnQ1Yw5FaGeiL/S3aKagQmr0I2wcHsM=; b=EG36Lj0ybMhd5j2PrQOKOul4oCYlJiBeuFc8prqNUaN6LgulW6m0242ESQPBpMolvc KOkk/4Z8NxiVsJceX8VV04kH677uBEG/l0B5YHEH6dQo/4XXUbiIMoytDozv8tUeH6/X t6KlnK4nyVjQvOBih0VLKYVXN/+tHxBPcQKmyFLR20mRdwCSKQaT3rLVdwFxG/t2S/3b gsOMKndfMAlbWTod3KydaGGli9OKgmqZV29AQxk/M7n4B2Kxz946y4vmAZrWWAiMv/vb qr3GHT0l0UtezQtJHoDKYwin9TOlmTL0wrj1nRjbmgYuZbIgG6iiHDKeiTdDj+L3c4hS MddA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714323170; x=1714927970; 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=bNif3eZYUBF7BnQ1Yw5FaGeiL/S3aKagQmr0I2wcHsM=; b=M7MCq/8BflaUUjTraqEx4qBuPDm/23UjUOc0xkUOP7OLxvOzoFHDFBnZfxVfqj7YNt R2lGQwdIBNZ8b6Yfi+8l2toxNaRqVHHcUm31ZDvjJN176P53VP/QZeqq9p8lQ4/hWITA CvJ1C0sfany0jlOnbTCcDqdNkZPncQhvhZN70YdaRrjmtsKZQKyom2ZweyttDrD1brv2 380DhmrzGmVqbUNum3i1E48coMAAJzzBc0CtuBWwlpG3koFsTlpEzljeez1UIIkO2CpP fjibRPuQspzbuu2bGsXrX5UXMZOWWTtMX15cG5PGm/byLfHL8YD34dGo9tUe2bA6iSaS Myyg== X-Gm-Message-State: AOJu0YwejVFim9KPV6P6XSfu9QNAxqgsf5TsCn3rMcGudQntgVq9X+Ow McOhFCIrE9gXbeGfeGWWET/TPSa3ZblvdL15EcWLA+M9COvQiYp071WmiEOq X-Google-Smtp-Source: AGHT+IHwI4f2/3EPYL3CVLZdm8bIPUwaOQTPxm+126HqOchO2GjyaTG96YOLuGT5acIOa0MzHkJm8w== X-Received: by 2002:a5d:64cf:0:b0:34c:a95f:1114 with SMTP id f15-20020a5d64cf000000b0034ca95f1114mr3141383wri.40.1714323169770; Sun, 28 Apr 2024 09:52:49 -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?= Subject: [PATCH v2 1/7] x86/p2m: Add braces for better code clarity Date: Sun, 28 Apr 2024 16:52:36 +0000 Message-Id: <90082c0aa2047edf5764840f1903d1797ca4b902.1714322424.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š --- xen/arch/x86/mm/p2m.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index ce742c12e0..eb7996170d 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 Sun Apr 28 16:52:37 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: 13646081 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 DA328C4345F for ; Sun, 28 Apr 2024 16:53:15 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.713704.1114599 (Exim 4.92) (envelope-from ) id 1s17lo-0006W8-Og; Sun, 28 Apr 2024 16:52:56 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 713704.1114599; Sun, 28 Apr 2024 16:52:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s17lo-0006V4-IZ; Sun, 28 Apr 2024 16:52:56 +0000 Received: by outflank-mailman (input) for mailman id 713704; Sun, 28 Apr 2024 16:52:53 +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 1s17ll-0006DB-6O for xen-devel@lists.xenproject.org; Sun, 28 Apr 2024 16:52:53 +0000 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [2a00:1450:4864:20::429]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c004c654-057f-11ef-909a-e314d9c70b13; Sun, 28 Apr 2024 18:52:51 +0200 (CEST) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-344047ac7e4so2637578f8f.0 for ; Sun, 28 Apr 2024 09:52:51 -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 a12-20020a056000188c00b00347eb354b30sm27850921wri.84.2024.04.28.09.52.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 09:52:50 -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: c004c654-057f-11ef-909a-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714323171; x=1714927971; 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=muQF6XIlOcvgBSNEsl6TLFua9rrP8CEbsAqrDkhuigQ=; b=X/Y5pkodFpLXnOCb8+QdSGhlBlM6hEIX4IK9IY5yR7jH4jeCCGA+zwP9rbOJubc59X hZabz7TmcBI1j1haD0PAftjSZv0f0ZQOLtgrhb88rNHc8V18Szk8ZRVvhZs0WZb8WM0J 1St8XtezqQ0oq006UMdxGEBktSsr3Q/9XUvkTmnmgIA+r1Z10BqItW6X1SkbIhoRyDZY ojoJLAVzvdsob+zl7Nk5oMOO+Y1RByqctJpoWsI+axnoHZ1OxhHTdsdz8m17/dKfcXmC 2JAfaTmz7ag6CzYjNAQV5+fhM8sQ3FE5gYvwlZuJvjSFKmgdBt3vaNhZc50ewURTAzA/ drfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714323171; x=1714927971; 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=muQF6XIlOcvgBSNEsl6TLFua9rrP8CEbsAqrDkhuigQ=; b=aF1ZdIdcedYZcJPoEDpu/SLEdwjTBGalyU39LK5Nvqg+ULHA7zDrianmgkVan1lsnf enRns3w26sqertHiKI7/NeA0CS5Yz9BySjoTyJGpEYOoLQZ+olRgrXzoY+ESp0nQjvtm /dJ1fbm3u/zVkHuSA7u/cnRbJN/9F6MKef6spPHgW4fTmasCK1Iz3LyJIPPyFo2t1nQn UaFEeQvD4tuAJm8lZtBmGaGeR5BBHHxtloD55oLOnFYEDPcvhqD2eL0UwO6+7vj37S+1 C32nVDhYGX4kVIFSqjYu/AlpJECuwWmtzREjmJ9qzZYxGjHVW6v1jyeHodNxWIbtNW5h 9UXQ== X-Gm-Message-State: AOJu0Yx2MfVtjvFus6UTYYnHfsjfOR9fLxeNXqgmksFtTPmc10tNfoYK SAr5yiRxuk/HHuvqgTs2DyzicYwGHOJTo65cHxqTBx1IfwR2ZfR4nYUZgfgo X-Google-Smtp-Source: AGHT+IEYxuPWlCBgkUyK+vExZMpgUXm6GpD5YJWUhI8AK7vIaSHJ8Qt6J075uCwgQmd2u/tM2QoOmQ== X-Received: by 2002:adf:f7ca:0:b0:349:bb17:6e60 with SMTP id a10-20020adff7ca000000b00349bb176e60mr4054187wrq.2.1714323170707; Sun, 28 Apr 2024 09:52:50 -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 v2 2/7] tools/xl: Add max_altp2m parameter Date: Sun, 28 Apr 2024 16:52:37 +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 max_altp2m parameter to control the maximum number of altp2m views a domain can use. By default, if max_altp2m 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š --- Changed since v1: * Removed the change of xen/include/public/domctl.h (moved into future commit) * Removed corresponding assignment of xen_domctl_createdomain::max_altp2m in libxl_create.c (moved into future commit) * Clarify in commit message that this change is preparatory 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 | 8 ++++++++ tools/libs/light/libxl_types.idl | 1 + tools/xl/xl_parse.c | 4 ++++ 6 files changed, 24 insertions(+) -- 2.34.1 diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/helpers.gen.go index 78bdb08b15..4458d5bcbb 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.MaxAltp2M = uint32(xc.max_altp2m) 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.max_altp2m = C.uint32_t(x.MaxAltp2M) 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..7139bcf324 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 +MaxAltp2M uint32 VmtraceBufKb int Vpmu Defbool } diff --git a/tools/include/libxl.h b/tools/include/libxl.h index 62cb07dea6..c73d9f2ff1 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_MAX_ALTP2M + * If this is defined, then libxl supports setting the maximum number of + * alternate p2m tables. + */ +#define LIBXL_HAVE_MAX_ALTP2M 1 +#define LIBXL_MAX_ALTP2M_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..801f704a02 100644 --- a/tools/libs/light/libxl_create.c +++ b/tools/libs/light/libxl_create.c @@ -483,6 +483,14 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, return -ERROR_INVAL; } + if (b_info->max_altp2m == LIBXL_MAX_ALTP2M_DEFAULT) { + if ((libxl_defbool_val(b_info->u.hvm.altp2m) || + b_info->altp2m != LIBXL_ALTP2M_MODE_DISABLED)) + b_info->max_altp2m = 10; + else + b_info->max_altp2m = 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 470122e768..c887d8ea8c 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), + ("max_altp2m", uint32, {'init_val': 'LIBXL_MAX_ALTP2M_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 ab09d0288b..741668e10a 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -2061,6 +2061,10 @@ void parse_config_data(const char *config_source, } } + if (!xlu_cfg_get_long(config, "max_altp2m", &l, 1)) { + b_info->max_altp2m = l; + } + if (!xlu_cfg_get_long(config, "vmtrace_buf_kb", &l, 1) && l) { b_info->vmtrace_buf_kb = l; } From patchwork Sun Apr 28 16:52:38 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: 13646078 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 569E5C25B5F for ; Sun, 28 Apr 2024 16:53:14 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.713705.1114605 (Exim 4.92) (envelope-from ) id 1s17lp-0006be-3i; Sun, 28 Apr 2024 16:52:57 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 713705.1114605; Sun, 28 Apr 2024 16:52:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s17lo-0006aH-TA; Sun, 28 Apr 2024 16:52:56 +0000 Received: by outflank-mailman (input) for mailman id 713705; Sun, 28 Apr 2024 16:52:53 +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 1s17ll-0006D5-K6 for xen-devel@lists.xenproject.org; Sun, 28 Apr 2024 16:52:53 +0000 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [2a00:1450:4864:20::435]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id c06b1a9c-057f-11ef-b4bb-af5377834399; Sun, 28 Apr 2024 18:52:52 +0200 (CEST) Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-34cc606b1b1so832710f8f.3 for ; Sun, 28 Apr 2024 09:52:52 -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 a12-20020a056000188c00b00347eb354b30sm27850921wri.84.2024.04.28.09.52.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 09:52:51 -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: c06b1a9c-057f-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714323171; x=1714927971; 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=M5idciq4z6LmfOUeSzwtHh7qUWkne+GPf19nH7mQTjs=; b=B3qMhSGfexztesEivmOOtbRap/SGTDXaKGfzgnfQ4ZuMedQ58psaXrPWremG2EkFQm h5SKO4KCW2on7aZ2Z7iXUbcRn+q4Q6E9gAnLWuURCyMTybtx90Rf4xkRL8ik/gb0d06Z wlGr3Th5CI2IvUHKxIsLEwopRvEEDIYJ//w3qklMjIus6AuDCxWsplvN4jKuMUincTeP Z73CxzeX8ggdXevT6SUKr330/0AEC5ueMmskxnHFqGQy5VaAl4gTiN+sdce8Vo5N6cuO bRPFFJTDy6WOazyeCtIDRhs4CF5aLp3DsZzGvHQzjudM1OkRSPdTDV9CQNkNFulX5xXc sT9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714323171; x=1714927971; 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=M5idciq4z6LmfOUeSzwtHh7qUWkne+GPf19nH7mQTjs=; b=HcvM5/GyDSnpRzi2scmuXQjnXOrAeykqnvyGVYbhXBpV4hJj4gWH52ThJAYaYwKbAT fo+aPEfnUGSJs3xHvxmu+d5EIiQ2YWtX7KetBU3Asa0icJISC9iweLNAObkzKpFpe5yd SFmudR6DE8E2vKtcUSc1LLNRIimzFXfh/CKuzniBSmO8MhFXCNjUUggFPD43+xqCx92P anUZHHa6I+sPxI4J8kCde7btuufJnl96fADcqOHafZ+wi8Kjfuf9Cq/9qWIQHRhYBK1Q uHTFndWmeWYvNKv4U+Uhfx64cxsfTTuFAWqEoXS58SGB4JP4Jghf6kiCoVYaSyDleC+1 pUqA== X-Gm-Message-State: AOJu0YyEjJO0fTSppSxSejIuzV2b9ZQlXtmf5CFE+rBFpKeQgxUt5uZi Cuny5D/qQDKhnkpykh14L2m/kea5YQ/BAL0JVLY4j3TfrvpvK6ZVupoSF2Ii X-Google-Smtp-Source: AGHT+IEerUPMQuOhFt+8q/PpyY6msCrrYCRJPyCUi6jzS2ozwfAnnPxmDPcjPTrxWpRzPO+vKOQpWQ== X-Received: by 2002:a05:6000:4cc:b0:347:9e5a:3078 with SMTP id h12-20020a05600004cc00b003479e5a3078mr6708927wri.1.1714323171414; Sun, 28 Apr 2024 09:52:51 -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 v2 3/7] docs/man: Add max_altp2m parameter to the xl.cfg manual Date: Sun, 28 Apr 2024 16:52:38 +0000 Message-Id: <9261df7a64aee4c09843ba99c182a65ec2057771.1714322424.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 max_altp2m configuration parameter. Signed-off-by: Petr Beneš --- docs/man/xl.cfg.5.pod.in | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index 8f2b375ce9..2d4ea35736 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 Sun Apr 28 16:52:39 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: 13646080 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 9C7E9C25B4F for ; Sun, 28 Apr 2024 16:53:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.713707.1114620 (Exim 4.92) (envelope-from ) id 1s17lp-0006tR-Qw; Sun, 28 Apr 2024 16:52:57 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 713707.1114620; Sun, 28 Apr 2024 16:52:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s17lp-0006oc-KO; Sun, 28 Apr 2024 16:52:57 +0000 Received: by outflank-mailman (input) for mailman id 713707; Sun, 28 Apr 2024 16:52:54 +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 1s17lm-0006DB-NU for xen-devel@lists.xenproject.org; Sun, 28 Apr 2024 16:52:54 +0000 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [2a00:1450:4864:20::42c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c13de9c7-057f-11ef-909a-e314d9c70b13; Sun, 28 Apr 2024 18:52:53 +0200 (CEST) Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-34d1ede7e51so41002f8f.1 for ; Sun, 28 Apr 2024 09:52:53 -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 a12-20020a056000188c00b00347eb354b30sm27850921wri.84.2024.04.28.09.52.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 09:52:52 -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: c13de9c7-057f-11ef-909a-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714323173; x=1714927973; 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=gG2qDlDs6FcET6IkvKvIzyxAbXvB4EM9puOXHyIK3Fk=; b=UmY+zt5YEBNxr9fPYl0V7QfbvbQkcDtIqTTYyun3jEKj+00IS8PvmnmKAC1QB029yS /Nct6p+KlJyZZ1mefYBCuCudCq694hfZrNO507P77T753frESbEpE4Ee4rAPIfnf1hOO hzlyP6U9R63+In9oR4aKf9gF8+FLRsJefF5vwEzUhBXg8jQPCvbLlvi+EWtUZXZD9ZsQ JehppXyxi1RSjpglI2f28YAr0tGvQalWb2PRYOgjsCjx4f++IoVhuaNBqCm4yTKbx2Fg RYKPOIihEJyC/5lJa7URuAF/GMld6wdPNRg0RHU9UFYgRo9xywC0ojokReAATegONgFb 1s3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714323173; x=1714927973; 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=gG2qDlDs6FcET6IkvKvIzyxAbXvB4EM9puOXHyIK3Fk=; b=Jg3YolJGuS71DdxinVyFX4hH0zUnzLJOmxmjwcqgyuPdJrlWQPFmn6PviQa6ClK1L8 c7qVCU7E8X0fHJloU6lNHv18oyr8uO3I8ItqGJOqUIrla721Ffe4PC9nQs8sjjp0Ak9k XSEipsr3R8is6qQMM+Q0lHtRCGStMNghYUt1E+g8wGOoBOZ0cBcLH1cBF0q9OY3SJ02j CyL2a9pjB33pd9gWCp26gtRSqxbuMtLMQ6UdZ1G2OqxmYydSV6MbapUpJ1E9Q8GGyVp9 6OmQnUY27a4s9KmKr21ry3SIeED9lOYFEpRwvnkkZY/37mEC7lk97Wbqd8yOuFOB4aYK kTtw== X-Gm-Message-State: AOJu0Yz737sZ5gmkFD41SDHNv3ZSzAEz/yCkbnPaoRQnGkqbD0e7y0CI 4j4oOSJOu0WC2oznLdkBhSl80Nf0JVq/ew5dD+6UpAgiph34qmWw8NX+7ONC X-Google-Smtp-Source: AGHT+IEhJydV42L0RIL9pZt43uuLj0a7WV9IeE9FHT7aWIZRSYeNhGEb8EQ7KZFPcknKKOmd6VLt8g== X-Received: by 2002:a5d:4901:0:b0:34c:246c:1ee9 with SMTP id x1-20020a5d4901000000b0034c246c1ee9mr4952634wrq.59.1714323172466; Sun, 28 Apr 2024 09:52:52 -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 v2 4/7] x86: Make the maximum number of altp2m views configurable Date: Sun, 28 Apr 2024 16:52:39 +0000 Message-Id: <0041438ff7a5d5b2fad59b676f4ece80470bf3b3.1714322424.git.w1benny@gmail.com> 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 tables during domain 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š --- Changed since v1: * Added xen_domctl_createdomain::max_altp2m field to xen/include/public/domctl.h * Bumped the XEN_DOMCTL_INTERFACE_VERSION * More elaborate commit message xen/arch/x86/domain.c | 6 ++++ 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 | 4 +-- xen/arch/x86/mm/altp2m.c | 27 +++++++++++++++-- xen/arch/x86/mm/hap/hap.c | 6 ++-- xen/arch/x86/mm/mem_access.c | 14 ++++----- xen/arch/x86/mm/mem_sharing.c | 2 +- xen/arch/x86/mm/p2m-ept.c | 6 ++-- xen/arch/x86/mm/p2m.c | 50 +++++++++++++++---------------- xen/common/domain.c | 7 +++++ xen/include/public/domctl.h | 3 +- xen/include/xen/sched.h | 2 ++ 14 files changed, 94 insertions(+), 50 deletions(-) -- 2.34.1 diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 20e83cf38b..6b458f330c 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -685,6 +685,12 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config) return -EINVAL; } + if ( config->max_altp2m > MAX_EPTP ) + { + dprintk(XENLOG_INFO, "max_altp2m must be <= %u\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 0ce45b177c..9b70fe7cfc 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4633,6 +4633,12 @@ static int do_altp2m_op( goto out; } + if ( d->max_altp2m == 0 ) + { + rc = -EINVAL; + goto out; + } + if ( (rc = xsm_hvm_altp2mhvm_op(XSM_OTHER, d, mode, a.cmd)) ) goto out; @@ -5222,7 +5228,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->max_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..8f57f3a7f5 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->max_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..5bb0bcae81 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 INVALID_ALTP2M 0xffff +#define MAX_EPTP ((unsigned int)(PAGE_SIZE / sizeof(uint64_t))) #define MAX_NESTEDP2M 10 -#define MAX_ALTP2M 10 /* arbitrary */ -#define INVALID_ALTP2M 0xffff -#define MAX_EPTP (PAGE_SIZE / sizeof(uint64_t)) 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..2086bcb633 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->max_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->max_altp2m); if ( idx == vcpu_altp2m(v).p2midx ) return false; diff --git a/xen/arch/x86/mm/altp2m.c b/xen/arch/x86/mm/altp2m.c index a04297b646..c91e0fbfd1 100644 --- a/xen/arch/x86/mm/altp2m.c +++ b/xen/arch/x86/mm/altp2m.c @@ -13,6 +13,12 @@ void altp2m_vcpu_initialise(struct vcpu *v) { + struct domain *d = v->domain; + + /* Skip initialisation if no altp2m will be used. */ + if ( d->max_altp2m == 0 ) + return; + if ( v != current ) vcpu_pause(v); @@ -28,8 +34,13 @@ altp2m_vcpu_initialise(struct vcpu *v) void altp2m_vcpu_destroy(struct vcpu *v) { + struct domain *d = v->domain; struct p2m_domain *p2m; + /* Skip destruction if no altp2m was used. */ + if ( d->max_altp2m == 0 ) + return; + if ( v != current ) vcpu_pause(v); @@ -120,7 +131,13 @@ 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++ ) + + if ( (d->arch.altp2m_p2m = xzalloc_array(struct p2m_domain *, d->max_altp2m)) == NULL ) + { + return -ENOMEM; + } + + for ( i = 0; i < d->max_altp2m; i++ ) { d->arch.altp2m_p2m[i] = p2m = p2m_init_one(d); if ( p2m == NULL ) @@ -141,7 +158,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->max_altp2m; i++ ) { if ( !d->arch.altp2m_p2m[i] ) continue; @@ -149,6 +169,9 @@ void p2m_teardown_altp2m(struct domain *d) d->arch.altp2m_p2m[i] = NULL; p2m_free_one(p2m); } + + xfree(d->arch.altp2m_p2m); + d->arch.altp2m_p2m = NULL; } /* diff --git a/xen/arch/x86/mm/hap/hap.c b/xen/arch/x86/mm/hap/hap.c index d2011fde24..7aff5fa664 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->max_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->max_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->max_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..1bf40cb746 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) || + if ( altp2m_idx >= min(d->max_altp2m, MAX_EPTP) || d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)] == 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->max_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) || + if ( altp2m_idx >= min(d->max_altp2m, MAX_EPTP) || d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)] == 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->max_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) || + if ( altp2m_idx >= min(d->max_altp2m, MAX_EPTP) || d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)] == 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->max_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->max_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..3aaf1a3b8d 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->max_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..6b75fafd49 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->max_altp2m; i++ ) { struct p2m_domain *p2m; @@ -1500,7 +1500,7 @@ 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->max_altp2m)]; struct p2m_domain *hostp2m = p2m_get_hostp2m(d); struct ept_data *ept; @@ -1519,7 +1519,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->max_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 eb7996170d..a7144fc8e1 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->max_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->max_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->max_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->max_altp2m; i++ ) { if ( d->arch.altp2m_eptp[i] != mfn_x(INVALID_MFN) ) { @@ -1780,7 +1780,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->max_altp2m ) return rc; altp2m_list_lock(d); @@ -1886,8 +1886,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->max_altp2m); + p2m = d->arch.altp2m_p2m[array_index_nospec(idx, d->max_altp2m)]; p2m_lock(p2m); @@ -1912,7 +1912,7 @@ void p2m_flush_altp2m(struct domain *d) altp2m_list_lock(d); - for ( i = 0; i < MAX_ALTP2M; i++ ) + for ( i = 0; i < d->max_altp2m; i++ ) { p2m_reset_altp2m(d, i, ALTP2M_DEACTIVATE); d->arch.altp2m_eptp[i] = mfn_x(INVALID_MFN); @@ -1928,9 +1928,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->max_altp2m); - p2m = array_access_nospec(d->arch.altp2m_p2m, idx); + p2m = d->arch.altp2m_p2m[array_index_nospec(idx, d->max_altp2m)]; hostp2m = p2m_get_hostp2m(d); p2m_lock(p2m); @@ -1968,7 +1968,7 @@ 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 >= min(d->max_altp2m, MAX_EPTP) ) return rc; altp2m_list_lock(d); @@ -1995,7 +1995,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->max_altp2m; i++ ) { if ( d->arch.altp2m_eptp[i] != mfn_x(INVALID_MFN) ) continue; @@ -2017,7 +2017,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 >= min(d->max_altp2m, MAX_EPTP) ) return rc; rc = domain_pause_except_self(d); @@ -2030,7 +2030,7 @@ int p2m_destroy_altp2m_by_id(struct domain *d, unsigned int idx) if ( d->arch.altp2m_eptp[array_index_nospec(idx, MAX_EPTP)] != mfn_x(INVALID_MFN) ) { - p2m = array_access_nospec(d->arch.altp2m_p2m, idx); + p2m = d->arch.altp2m_p2m[array_index_nospec(idx, d->max_altp2m)]; if ( !_atomic_read(p2m->active_vcpus) ) { @@ -2055,7 +2055,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->max_altp2m ) return rc; rc = domain_pause_except_self(d); @@ -2090,13 +2090,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) || + if ( idx >= min(d->max_altp2m, MAX_EPTP) || d->arch.altp2m_eptp[array_index_nospec(idx, MAX_EPTP)] == 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->max_altp2m)]; p2m_lock(hp2m); p2m_lock(ap2m); @@ -2152,7 +2152,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->max_altp2m; i++ ) { p2m_type_t t; p2m_access_t a; @@ -2175,7 +2175,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->max_altp2m; i++ ) { if ( i == last_reset_idx || d->arch.altp2m_eptp[i] == mfn_x(INVALID_MFN) ) @@ -2575,12 +2575,12 @@ 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) || + if ( sve->view >= min(d->max_altp2m, MAX_EPTP) || d->arch.altp2m_eptp[array_index_nospec(sve->view, MAX_EPTP)] == 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->max_altp2m)]; } p2m_lock(host_p2m); @@ -2643,12 +2643,12 @@ 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) || + if ( altp2m_idx >= min(d->max_altp2m, MAX_EPTP) || d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)] == 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->max_altp2m)]; } else p2m = host_p2m; @@ -2679,9 +2679,9 @@ 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). + * min(d->max_altp2m, MAX_EPTP). */ - if ( altp2m_idx >= min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) || + if ( altp2m_idx >= min(d->max_altp2m, MAX_EPTP) || d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)] == mfn_x(INVALID_MFN) ) rc = -EINVAL; diff --git a/xen/common/domain.c b/xen/common/domain.c index 6773f7fb90..18785cc22a 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -568,6 +568,12 @@ static int sanitise_domain_config(struct xen_domctl_createdomain *config) } } + if ( config->max_altp2m && !hvm_altp2m_supported() ) + { + dprintk(XENLOG_INFO, "altp2m requested but not available\n"); + return -EINVAL; + } + if ( config->vmtrace_size && !vmtrace_available ) { dprintk(XENLOG_INFO, "vmtrace requested but not available\n"); @@ -610,6 +616,7 @@ struct domain *domain_create(domid_t domid, if ( config ) { d->options = config->flags; + d->max_altp2m = config->max_altp2m; d->vmtrace_size = config->vmtrace_size; } diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index a33f9ec32b..f9bd0ffe1a 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. @@ -77,6 +77,7 @@ struct xen_domctl_createdomain { */ uint32_t max_vcpus; uint32_t max_evtchn_port; + uint32_t max_altp2m; int32_t max_grant_frames; int32_t max_maptrack_frames; diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 132b841995..46436fcb0b 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 max_altp2m; /* Maximum number of altp2m tables */ + unsigned int vmtrace_size; /* Buffer size in bytes, or 0 to disable. */ #ifdef CONFIG_ARGO From patchwork Sun Apr 28 16:52:40 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: 13646075 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 68C16C10F1A for ; Sun, 28 Apr 2024 16:53:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.713706.1114612 (Exim 4.92) (envelope-from ) id 1s17lp-0006hE-Cy; Sun, 28 Apr 2024 16:52:57 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 713706.1114612; Sun, 28 Apr 2024 16:52:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s17lp-0006g6-4r; Sun, 28 Apr 2024 16:52:57 +0000 Received: by outflank-mailman (input) for mailman id 713706; Sun, 28 Apr 2024 16:52:54 +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 1s17lm-0006DB-GN for xen-devel@lists.xenproject.org; Sun, 28 Apr 2024 16:52:54 +0000 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [2a00:1450:4864:20::429]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c186c588-057f-11ef-909a-e314d9c70b13; Sun, 28 Apr 2024 18:52:53 +0200 (CEST) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-34ce52fb920so551562f8f.3 for ; Sun, 28 Apr 2024 09:52:54 -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 a12-20020a056000188c00b00347eb354b30sm27850921wri.84.2024.04.28.09.52.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 09:52:52 -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: c186c588-057f-11ef-909a-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714323173; x=1714927973; 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=C94PBg2Ugq5+o7rPz1hPA2wsUOkB+FxnEHaAoO6c8iQ=; b=HwBnLqZTKkJb9dS3dRPq8VsSWoUXAU3ShtPKfaVOr1nZ6uzn+h4by2f+xv3GdAYjue O7bq91IbkBMFL4FQ0lkWwVA+89g52+sTG+gZQqYOpwKxgPPrjjbTfD4gZiw/4htI4Fi4 EJ+XWRPCbU/p1w4oIS1T2Z1RuelYbpQ6U6XX3zp28RifC4f0N2nsVFYbF5vUknnroJAK ZCmdvlmM5vUn2chcqmKkp9Slbg7tQSbHUMR/CSMr4txJYZoRHEC1VuutwdQ+arlHOAar ls428UM6/Tgueo0P8PEorJUXGi7dN2aDJPaPt+zgap8nA797LMX2LbVhZwP5PGO7Jrt0 4HnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714323173; x=1714927973; 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=C94PBg2Ugq5+o7rPz1hPA2wsUOkB+FxnEHaAoO6c8iQ=; b=aicaupT6ywjlmBpdZl8Bg2uV8mG69qcYCdGY/W3buJBbr6xIurRITgZaK2SC+ju0l/ z9Ajq+Drb0jLH61PKJJwoiA7A7CwyYckCV201uwGia/ViH0qBDtT3P+WAUbNNmgn6rhi KnbWzybeYJ6Hppw9I0/2lqfvOChRxDYhL28FtDTwX6Qzac0vBl05B1uHQQfrgF+I5b/B gmpydTsR9veaS/M7tg16ENTfwCCWa056ESu6jgM4uwyPVt5JrecuYFMs14S68NVvxICr AhpvRhhWpR7GceEww0Q5kkP7Kj4yfpQMwl2dgWZfkbgc9V1bZgCB361vr5TChuMM7MIF ZPbQ== X-Gm-Message-State: AOJu0YyYjux0TBAw4PEUuAX6B/vnnH7LVRBaQ+nnvdRozlagpD3Amh7y FyiIGprP89te9rtQ355pAv+qKNZwW8f4CI/BHETXfMCMJbFZeIkZ5U/X1rKf X-Google-Smtp-Source: AGHT+IEAAnK63VjnM7MqGDPEzwDD4kfdpqcuHqgEOQAvsV+JWzA/yMvhRCk+lSZGP5am51FRJDfJ5g== X-Received: by 2002:adf:e741:0:b0:34d:1692:4463 with SMTP id c1-20020adfe741000000b0034d16924463mr363777wrn.19.1714323173264; Sun, 28 Apr 2024 09:52:53 -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 v2 5/7] tools/libxl: Activate the max_altp2m feature Date: Sun, 28 Apr 2024 16:52:40 +0000 Message-Id: <934ec36f587318b9992dfbce2046ea1d97115f24.1714322424.git.w1benny@gmail.com> 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 max_altp2m parameter, establishing the connection between libxl and Xen. Signed-off-by: Petr Beneš --- Changed since v1: * This is a new commit in the series 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 801f704a02..6ccc1fa158 100644 --- a/tools/libs/light/libxl_create.c +++ b/tools/libs/light/libxl_create.c @@ -653,6 +653,7 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config, .ssidref = info->ssidref, .max_vcpus = b_info->max_vcpus, .max_evtchn_port = b_info->event_channels, + .max_altp2m = b_info->max_altp2m, .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), From patchwork Sun Apr 28 16:52:41 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: 13646077 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 B38B8C41513 for ; Sun, 28 Apr 2024 16:53:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.713708.1114631 (Exim 4.92) (envelope-from ) id 1s17lq-0007Ai-Ll; Sun, 28 Apr 2024 16:52:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 713708.1114631; Sun, 28 Apr 2024 16:52:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s17lq-00078Q-BJ; Sun, 28 Apr 2024 16:52:58 +0000 Received: by outflank-mailman (input) for mailman id 713708; Sun, 28 Apr 2024 16:52:55 +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 1s17ln-0006DB-Hy for xen-devel@lists.xenproject.org; Sun, 28 Apr 2024 16:52:55 +0000 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [2a00:1450:4864:20::329]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c210c00a-057f-11ef-909a-e314d9c70b13; Sun, 28 Apr 2024 18:52:54 +0200 (CEST) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-41c011bb920so3226105e9.1 for ; Sun, 28 Apr 2024 09:52:54 -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 a12-20020a056000188c00b00347eb354b30sm27850921wri.84.2024.04.28.09.52.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 09:52:53 -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: c210c00a-057f-11ef-909a-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714323174; x=1714927974; 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=IAwmfpqE/egFzfCs4yP798ggKDGpEceOhDUHTa8HbXM=; b=JZfY3dZADAEY/bhbmEYVlyInpCjsF7UpM+OgZr3ebzUZuT1QvWfCDlx3s/D6WJclst d8yRYj8cvYxRJ2VKVTyCRBfvCu2jZlQaYY9bp7clwVLuLKortV2iIKQeZixrXwSj8LDm kLu3lG0cts0imwtKxjwq5GDOoLMc8lLS+m3qO0cGPCZAneUnhxxC4jbLAWnBR91PaKwj hGmBay3lNkuxPWaLtuplaemX9Qi5psIrkQOTowIViBLJ6j3FqCh5mFTMjMyD4dW6BeIs qz57xsyF/rSY0pOI+8vfUYDdLb4CRIIB4CPwu2j7Uz4hrDswSFFPPxFeCGA1QEYG4cDL +THw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714323174; x=1714927974; 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=IAwmfpqE/egFzfCs4yP798ggKDGpEceOhDUHTa8HbXM=; b=BDnZHywUzqm/nWebTt8BL3HW9rwlOEOqTZ4nV/In7FWlzwJ17E5SK0egFfevHVgaKR mqEaoskRsMCkZQMNK/2aR+heP3eDHDZzc3YA5PHsgG+3hGCOWt+9ag7CgRIUk2lDYVE+ SlrDuLwFQVPdQ1QjJa8kZAn1JlqCZJe3kz9vOCTszeSb0/8SkS21IVsP3THmj548RKok 01QJ6K5muCkjfoeez6nvgw0WUSmoRNZR8LsaR8thrzZ+mT+aBTrS9kQQSsedKmPl8xVo bcNSH+Pp/ekY26+ggD+P57hvmBqOiuk1LRtojnGBC2MHozDO2mqV+zraJuiwGY74zbL4 Bynw== X-Gm-Message-State: AOJu0YzwHNvWONx13a03mgrSbogzdCSy2lYlCKeSBP4eTT5d7dohpEt6 u1O2hPnNaLuJx5v5INzpaOdYjXYEqKgAba27d/050RO8lNkOVewjT01BCqvG X-Google-Smtp-Source: AGHT+IGq0+nmVUU5KPNzGw0CrBY4sV1Zukh+Mb6LdwpqptkXPO/nzbXcviIP2k2Hokvv74TanC8H+g== X-Received: by 2002:a05:600c:4e8a:b0:418:9d4a:1ba5 with SMTP id f10-20020a05600c4e8a00b004189d4a1ba5mr4547338wmq.6.1714323174191; Sun, 28 Apr 2024 09:52:54 -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 v2 6/7] tools/ocaml: Add max_altp2m parameter Date: Sun, 28 Apr 2024 16:52:41 +0000 Message-Id: <32c3c312635e943c76329d52efb8ff71f5ee740f.1714322424.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 max_altp2m parameter. Signed-off-by: Petr Beneš Acked-by: Christian Lindig --- Changed since v1: * Moved this commit AFTER Xen changes (where xen_domctl_createdomain::max_altp2m field is introduced) to avoid breaking the build tools/ocaml/libs/xc/xenctrl.ml | 1 + tools/ocaml/libs/xc/xenctrl.mli | 1 + tools/ocaml/libs/xc/xenctrl_stubs.c | 17 ++++++++++------- 3 files changed, 12 insertions(+), 7 deletions(-) -- 2.34.1 diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml index 55923857ec..ed851bb071 100644 --- a/tools/ocaml/libs/xc/xenctrl.ml +++ b/tools/ocaml/libs/xc/xenctrl.ml @@ -82,6 +82,7 @@ type domctl_create_config = iommu_opts: domain_create_iommu_opts list; max_vcpus: int; max_evtchn_port: int; + max_altp2m: int; max_grant_frames: int; max_maptrack_frames: int; max_grant_version: int; diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.mli index 9b4b45db3a..971b269d85 100644 --- a/tools/ocaml/libs/xc/xenctrl.mli +++ b/tools/ocaml/libs/xc/xenctrl.mli @@ -74,6 +74,7 @@ type domctl_create_config = { iommu_opts: domain_create_iommu_opts list; max_vcpus: int; max_evtchn_port: int; + max_altp2m: int; max_grant_frames: int; max_maptrack_frames: int; max_grant_version: int; diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenctrl_stubs.c index 2b6d3c09df..0b70cc9b08 100644 --- a/tools/ocaml/libs/xc/xenctrl_stubs.c +++ b/tools/ocaml/libs/xc/xenctrl_stubs.c @@ -207,12 +207,13 @@ CAMLprim value stub_xc_domain_create(value xch_val, value wanted_domid, value co #define VAL_IOMMU_OPTS Field(config, 3) #define VAL_MAX_VCPUS Field(config, 4) #define VAL_MAX_EVTCHN_PORT Field(config, 5) -#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_MAX_ALTP2M Field(config, 6) +#define VAL_MAX_GRANT_FRAMES Field(config, 7) +#define VAL_MAX_MAPTRACK_FRAMES Field(config, 8) +#define VAL_MAX_GRANT_VERSION 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); @@ -226,6 +227,7 @@ CAMLprim value stub_xc_domain_create(value xch_val, value wanted_domid, value co .ssidref = Int32_val(VAL_SSIDREF), .max_vcpus = Int_val(VAL_MAX_VCPUS), .max_evtchn_port = Int_val(VAL_MAX_EVTCHN_PORT), + .max_altp2m = Int_val(VAL_MAX_ALTP2M), .max_grant_frames = Int_val(VAL_MAX_GRANT_FRAMES), .max_maptrack_frames = Int_val(VAL_MAX_MAPTRACK_FRAMES), .grant_opts = @@ -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) @@ -291,6 +293,7 @@ CAMLprim value stub_xc_domain_create(value xch_val, value wanted_domid, value co #undef VAL_MAX_GRANT_VERSION #undef VAL_MAX_MAPTRACK_FRAMES #undef VAL_MAX_GRANT_FRAMES +#undef VAL_MAX_ALTP2M #undef VAL_MAX_EVTCHN_PORT #undef VAL_MAX_VCPUS #undef VAL_IOMMU_OPTS From patchwork Sun Apr 28 16:52:42 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: 13646079 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 5D5EEC25B73 for ; Sun, 28 Apr 2024 16:53:14 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.713709.1114637 (Exim 4.92) (envelope-from ) id 1s17lq-0007IC-Tf; Sun, 28 Apr 2024 16:52:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 713709.1114637; Sun, 28 Apr 2024 16:52:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s17lq-0007GD-NT; Sun, 28 Apr 2024 16:52:58 +0000 Received: by outflank-mailman (input) for mailman id 713709; Sun, 28 Apr 2024 16:52:56 +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 1s17lo-0006DB-Gl for xen-devel@lists.xenproject.org; Sun, 28 Apr 2024 16:52:56 +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 c296f8e1-057f-11ef-909a-e314d9c70b13; Sun, 28 Apr 2024 18:52:55 +0200 (CEST) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-41adf3580dbso20948005e9.0 for ; Sun, 28 Apr 2024 09:52:55 -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 a12-20020a056000188c00b00347eb354b30sm27850921wri.84.2024.04.28.09.52.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 09:52:54 -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: c296f8e1-057f-11ef-909a-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714323175; x=1714927975; 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=uRmhbnTJStHi1KkjxYIGvbfG3WE3teBkCarxEGq+EPc=; b=VGV8AeblDbsOxKIJldsP4cjmhqio9yRaTagX0M4HuCDRLPXDWYIgUdiBu6RcrykjuL 2f4yc5aCR8eW7T0gqymLRrlUp38n8SkNkrXGl5e2bF8nwU3QQ8QdTYuY8V2usSX8sg+1 mIVwkVBTu79ZGis+g75zPXrcxgAexw6yNLXtgHX3/613b//K0cDcPUpRS+wS3scN1boq Omu9vn8658SpMYuklk4gEQyx9dDO7CEKCWLjUGFaIGrRrnA+SfHacjOl4bCMOHDxeuzl RRpETV8+D6THJbOav5fn7faBZ3RQnn5It9GeCBJGRgH/TvxeK3f73RO9+sT8+D8WsOlD S7dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714323175; x=1714927975; 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=uRmhbnTJStHi1KkjxYIGvbfG3WE3teBkCarxEGq+EPc=; b=EIrYdJFgCE3XHB9MjYLHhe7GHLn81QBvLC04Ue2wAQpPPcMpn/dleEgUO672ED9w93 /Xik+McYlDFyfVguadqc8yxSfgmrRo7E781e9EujxP8nDFHs3bnva9HIfsfLjWQZFn4P /jt1vI3iopbDDyWUPNggqK9QK+7Yn9skrHzhWr+Rs1aQQ1dyr07SN5MDdJ2+FBBNCCD0 30WbMH/sTJpqxHn3GvstVAZB28vdUdSua9Qv3YJu1LWE7jPZwBy0r6HA1sVE/O6WjEzE LAYI1tZA3ESyi4grSjvA8noV/Tmf3gstItc5bUJVVO+atxVuQcCyaZ7C04irAVjkYq0h /ydQ== X-Gm-Message-State: AOJu0YxsZqrYIi7MjT9LMct34ZxM1fXJyqwHUMYQiR0AMdYZrPB08lOQ 5NHF74ELoWxov9vEpx74EWtu4g4y31wbqzraWtpASpl2mc8tRpzrY8NWP687 X-Google-Smtp-Source: AGHT+IE/5HJoBtmMIjJcoejHquMqcOjnqeFgg34BEa/OWG1DnI5wPeGzp6pPW3gpJoK8tHMRC0MmBA== X-Received: by 2002:a05:600c:1d16:b0:418:5ef3:4a04 with SMTP id l22-20020a05600c1d1600b004185ef34a04mr7707461wms.18.1714323175061; Sun, 28 Apr 2024 09:52:55 -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 , Jan Beulich , Andrew Cooper , George Dunlap , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v2 7/7] x86/hap: Increase the number of initial mempool_size to 1024 pages Date: Sun, 28 Apr 2024 16:52:42 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 From: Petr Beneš This change anticipates scenarios where `max_altp2m` is set to its maximum supported value (i.e., 512), ensuring sufficient memory is allocated upfront to accommodate all altp2m tables without initialization failure. The necessity for this increase arises from the current mechanism where altp2m tables are allocated at initialization, requiring one page from the mempool for each altp2m view. Signed-off-by: Petr Beneš --- tools/tests/paging-mempool/test-paging-mempool.c | 2 +- xen/arch/x86/mm/hap/hap.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/tests/paging-mempool/test-paging-mempool.c b/tools/tests/paging-mempool/test-paging-mempool.c index 1ebc13455a..91b06fa0cf 100644 --- a/tools/tests/paging-mempool/test-paging-mempool.c +++ b/tools/tests/paging-mempool/test-paging-mempool.c @@ -35,7 +35,7 @@ static struct xen_domctl_createdomain create = { static uint64_t default_mempool_size_bytes = #if defined(__x86_64__) || defined(__i386__) - 256 << 12; /* Only x86 HAP for now. x86 Shadow needs more work. */ + 1024 << 12; /* Only x86 HAP for now. x86 Shadow needs more work. */ #elif defined (__arm__) || defined(__aarch64__) 16 << 12; #endif diff --git a/xen/arch/x86/mm/hap/hap.c b/xen/arch/x86/mm/hap/hap.c index 7aff5fa664..fab7e256a4 100644 --- a/xen/arch/x86/mm/hap/hap.c +++ b/xen/arch/x86/mm/hap/hap.c @@ -468,7 +468,7 @@ int hap_enable(struct domain *d, u32 mode) if ( old_pages == 0 ) { paging_lock(d); - rv = hap_set_allocation(d, 256, NULL); + rv = hap_set_allocation(d, 1024, NULL); if ( rv != 0 ) { hap_set_allocation(d, 0, NULL);