From nobody Sun Apr 28 03:26:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1652816529; cv=none; d=zohomail.com; s=zohoarc; b=ABtlSjgo98f+S6M19gXSotDTUkcQxOM3+khOwUeoqCN79yKVLgPaUCDK7nTguMGJpT72cHapAV+k7lqRT3OUWw+39AjnWWB3ZLBCJhcDQIR4iHq8iuhWCoKyjJYQXOxRvXJP2acu4HamvpPut4lwcQ3a05sAGThe+RL3+GwpAkA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652816529; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=v/ztTEoldoO9G+aVPVLguGLxmwaqmJzR8RLqIPQ59/I=; b=Tu8u908SMG6vsZw37zQRMsPSK/XHtA7syKrnfSaflYIUtNq2jlxvWRlyxE6o35eDvn15aDqr/TaEw7fWQt0FmRXhEvmPlb3nCuKs8i3CFrguS3fnCreSrkGfvWBO71il4XAkoWyPyliemcEx/dbIUUIvm76CdyoEoqbS36bhGoU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1652816529411719.85090921062; Tue, 17 May 2022 12:42:09 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.331458.554981 (Exim 4.92) (envelope-from ) id 1nr34h-0001wx-Aw; Tue, 17 May 2022 19:41:43 +0000 Received: by outflank-mailman (output) from mailman id 331458.554981; Tue, 17 May 2022 19:41:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nr34h-0001wo-8K; Tue, 17 May 2022 19:41:43 +0000 Received: by outflank-mailman (input) for mailman id 331458; Tue, 17 May 2022 19:41:42 +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 1nr34g-0001wE-D0 for xen-devel@lists.xenproject.org; Tue, 17 May 2022 19:41:42 +0000 Received: from esa3.hc3370-68.iphmx.com (esa3.hc3370-68.iphmx.com [216.71.145.155]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 5e4c22c5-d619-11ec-bd2c-47488cf2e6aa; Tue, 17 May 2022 21:41:40 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 5e4c22c5-d619-11ec-bd2c-47488cf2e6aa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1652816500; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=vnkTDze3G4oFOaHVWufMPnc4Xim+l6INdmwqKwzAzBc=; b=IopsoZYcgWM3VmNXwNExevkOpDvh6dVLO+j8hs72glae7McHlF/Hd0WA UeoVDyLZswu4K1PYr2O2xc5pPfj2nfJtn/7D7q5Y/fp8EXsom2z/j29Wh NRWsvM6rVMKvZ773Jam6DyXE96BQ0PNyApsj8jf34/SCnbSfSiVN3RR6p k=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 5.1 X-MesageID: 71530633 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:QB/tyajVZOaFHuG4PLaS3DGYX161aRAKZh0ujC45NGQN5FlHY01je htvXmzSa/iNZDb8eNFxO46//BsCsZ/TyNU1HlA9qS03Fnkb9cadCdqndUqhZCn6wu8v7a5EA 2fyTvGacajYm1eF/k/F3oDJ9CU6jefSLlbFILas1hpZHGeIcw98z0M68wIFqtQw24LhXlrS4 YmaT/D3YzdJ5RYlagr41IrbwP9flKyaVOQw5wFWiVhj5TcyplFNZH4tDfjZw0jQG+G4KtWSV efbpIxVy0uCl/sb5nFJpZ6gGqECaua60QFjERO6UYD66vRJjnRaPqrWqJPwwKqY4tmEt4kZ9 TlDiXC/YUAyP/L9v89AaUJFNihsZZ8Y34LGBXfq5KR/z2WeG5ft6/BnDUVwNowE4OdnR2pJ8 JT0KhhUMErF3bjvhuvmFK883azPL+GyVG8bklhmwSvUErANRpfbTr+RzdRZwC0xloZFGvO2i 88xNmMyN0yeOEYn1lE/LpQ8l8ywjGvEcWdosgKE+u0nxmjew1kkuFTqGIWMIYHbLSlPpW6Uq GvJ8GX+BhAyL8GExHyO9XfEruvSliq9VosUH7C88uNCiUeWgGcUDXU+RVa95PW0lEO6c9ZeM FAPvDojq7Ao806mRcW7WAe3yFaGsQQbQMF4CPAh5UeGza+83uqCLjFaFHgbMoVg7ZJoA2xxv rOUoz/3LXt0seKkblnAzOyJiDqgYRpLClIDQSBRGGPp/OLfiI00ixvOSPNqH6i0ksD5FFnM/ tyakMQtr+5N1JBWjs1X6XiC2mvx/caREmbZ8y2NBgqYAhVFiJlJjmBCwXzS9r5+IYmQVTFtV 1BUypHFvIji4Xxg/RFhodnh/pn0vp5p0xWG2DaD+qXNEBz0ohaekXh4um0WGauQGp9slcXVS EHSoxhNw5RYIWGna6R6C6roVZlwnfG6SYm8CKuMBjarXnSWXFbXlByCmGbKhzy9+KTSuf9X1 WinnTaEUi9BVPUPIMueTOYBy747rh3SNkuILa0XOy+PiOLEDFbMEO9tGALXMogRsfLfyC2Io ok3Cid/40gGOAEISnKPodB7wJFjBSVTOK0aXOQMKLLSelc8STh4YxITqJt4E7FYc21uvr+g1 hmAtoVwkTITWVWvxd22V01e IronPort-HdrOrdr: A9a23:d5IKDqrWHMe8to6ujUaAKlgaV5rReYIsimQD101hICG9Evb0qy lhppQmPH7P+VIssRQb8+xoV5PufZqxz/BICOoqTNKftWvdyQiVxehZhOOP/9SJIUbDH4VmpM VdmsZFaeEZDTJB/LvHCAvTKadd/DFQmprY+ts3zB1WPH9Xg7kL1XYfNu4CeHcGPzWvA/ACZf yhz/sCnRWMU1INYP+2A3EUNtKz3eEixPrdEGc77wdM0nj3sQ+V X-IronPort-AV: E=Sophos;i="5.91,233,1647316800"; d="scan'208";a="71530633" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Juergen Gross , Dario Faggioli , Luca Fancellu Subject: [PATCH 1/2] xen/cpupool: Reject attempts to add a domain to CPUPOOLID_NONE Date: Tue, 17 May 2022 20:41:12 +0100 Message-ID: <20220517194113.2574-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20220517194113.2574-1-andrew.cooper3@citrix.com> References: <20220517194113.2574-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1652816530382100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" c/s cfc52148444f ("xen/domain: Reduce the quantity of initialisation for system domains") removed the path in domain_create() which called sched_init_domain() with CPUPOOLID_NONE for system domains. Arguably, that changeset should have cleaned up this path too. However, c/s 92ea9c54fc81 ("arm/dom0less: assign dom0less guests to cpupool= s") changed domain_create() from using a hardcoded poolid of 0, to using a value passed by the toolstack. While CPUPOOLID_NONE is an internal constant, userspace can pass -1 for the cpupool_id parameter and attempt to construct a real domain using default o= ps, which at a minimum will fail the assertion in dom_scheduler(). Fixes: 92ea9c54fc81 ("arm/dom0less: assign dom0less guests to cpupools") Signed-off-by: Andrew Cooper Reviewed-by: Juergen Gross Reviewed-by: Luca Fancellu Tested-by: Luca Fancellu --- CC: Juergen Gross CC: Dario Faggioli CC: Luca Fancellu --- xen/common/sched/cpupool.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/xen/common/sched/cpupool.c b/xen/common/sched/cpupool.c index f6e3d97e5288..f1aa2db5f463 100644 --- a/xen/common/sched/cpupool.c +++ b/xen/common/sched/cpupool.c @@ -619,8 +619,6 @@ int cpupool_add_domain(struct domain *d, unsigned int p= oolid) int rc; int n_dom =3D 0; =20 - if ( poolid =3D=3D CPUPOOLID_NONE ) - return 0; spin_lock(&cpupool_lock); c =3D cpupool_find_by_id(poolid); if ( c =3D=3D NULL ) --=20 2.11.0 From nobody Sun Apr 28 03:26:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1652816530; cv=none; d=zohomail.com; s=zohoarc; b=gYOEyNY3mnN+0hL/mOqw3YL8XRH2JYlCc6XqPXcOHz4U9ohRMSvtZoYlep+lxnS9ZOt0y1HsJFtIn55EHFMmUC4dXntclDQfODd4SUM32TP08LZVh92Wg3fH+k7jD3YY5ZGkOpZV2PtRL0KmvD1atrtleHE+J+tD+gssKhJBymU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652816530; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=r1Dz79FrSCriiUVaZkkSf+bIY2FFoFqkoPnR88CU60I=; b=ZeoiTEvEDfqunkupSLLjApbED76/n0QgLP0qOioudBRyfUMZVgV1eY4EOJrRUBWHAP0/xTU6vFMa5OIbi6DcL3xvF+e345eFjAwNSy338huTtjijlKoK9HGt01q3qgi7xU8Q1260pdBKLKC2mFSSjQ7ThL5tqoug9LLswt5Aqi8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1652816530344195.0829602818268; Tue, 17 May 2022 12:42:10 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.331457.554969 (Exim 4.92) (envelope-from ) id 1nr34d-0001gc-4K; Tue, 17 May 2022 19:41:39 +0000 Received: by outflank-mailman (output) from mailman id 331457.554969; Tue, 17 May 2022 19:41:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nr34d-0001gV-1M; Tue, 17 May 2022 19:41:39 +0000 Received: by outflank-mailman (input) for mailman id 331457; Tue, 17 May 2022 19:41:38 +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 1nr34c-0001gP-La for xen-devel@lists.xenproject.org; Tue, 17 May 2022 19:41:38 +0000 Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 5be0e18d-d619-11ec-837e-e5687231ffcc; Tue, 17 May 2022 21:41:36 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 5be0e18d-d619-11ec-837e-e5687231ffcc DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1652816496; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aBugvKDimbdDHpVRY9poQsYTk8AfjAaSmNls4jiErmU=; b=G6RbNV2L6ofpWqbQ4BF5EtrLZAjxaKv+4/02f5halT9S2DB7LiaXeFmn HgKt3SDWFyQKU088hdhC2wXR9KP/5tDlgZjDYPnONosBE5vqpUDhAb73F FJ+H1YHij8opS4U9wus+W4fDwFRqEwoVWW6fjk2RE4EXrXIT7elH7aS3S k=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 5.1 X-MesageID: 71543646 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:jZw2kq7coxSGItJ8P3WKiAxRtFrHchMFZxGqfqrLsTDasY5as4F+v jAfC2qDPfqPZTb1eNlyb9y3pBsAuMfSz9I3Swtp/CE0Hi5G8cbLO4+Ufxz6V8+wwmwvb67FA +E2MISowBUcFyeEzvuVGuG96yE6j8lkf5KkYAL+EnkZqTRMFWFw0HqPp8Zj2tQy2YXgXFvX0 T/Pi5a31GGNimYc3l08s8pvmDs31BglkGpF1rCWTakjUG72zxH5PrpGTU2CByKQrr1vNvy7X 47+IISRpQs1yfuP5uSNyd4XemVSKlLb0JPnZnB+A8BOiTAazsA+PzpS2FPxpi67hh3Q9+2dx umhurSZUyx1YKvpqt8DDTQBSRAnPaZh4YLYdC3XXcy7lyUqclPpyvRqSko3IZcZ6qB8BmQmG f4wcW5XKErZ3qTvnez9GrIEascLdaEHOKs2vH16wC6fJvEhWZ3ZGI3B5MNC3Sd2jcdLdRrbT 5VANGY0MkieC/FJEmo9Fq4xrOWPvVX+Uj97jnyZmooovFGGmWSd15CyaYGIK7RmX/59mluTr yTI9mLyDxUeKfSW0z/D+XWp7sffkCW+VI8MGbmQ8v9xnEbV1mEVEAcRV1awvb++kEHWZj5EA xVKoGx09/F0rRH1CImmN/GlnJKaljcGcIYOFcgI0x/T5/OO0l+ZDU8dcyEUPbTKq/QKbTAt0 1aImfbgCjpurKCZRBqhy1uEkd+hEXNLdDFfPEfoWSNAuoC++99r0nojW/45SMaIYsvJ9SYcK txghAw3nP0tgMECzM1XFniX0mv39vAlouPYjzg7v15JDCskPeZJhKTysDA3CMqsy67AFzG8U IAswZT20Qz3JcjleNaxaOsMBqq1wP2OLSfRh1Vid7F4qWn3qyf5Id0JvmomTKuMDirjUWa5C HI/RCsLvMMDVJdURfEfj32N5zQCkvG7SIWNugH8ZdtSeJlhHDJrDwk1DXN8K1vFyRB2+YlmY M/zWZ/1UR4yVPU8pBLrFrh17FPe7n1nrY8lbcujn0rPPHv3TCP9dIrpx3PVMLxotP7e8VyMm zudXuPToyhivCTFSnG/2eYuwZoidxDX2bieRxRrS9O+ IronPort-HdrOrdr: A9a23:4/aJ8qNHgQ/9j8BcTvujsMiBIKoaSvp037Eqv3oRdfUzSL3hqy nOpoVj6faaskdzZJhNo7+90ey7MBfhHP1OkO8s1NWZLWvbUQKTRekIh+aP/9SjIVyYygc079 YaT0EUMr3N5DZB4/oSmDPIduod/A== X-IronPort-AV: E=Sophos;i="5.91,233,1647316800"; d="scan'208";a="71543646" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Christian Lindig , =?UTF-8?q?Edwin=20T=C3=B6r=C3=B6k?= , Luca Fancellu Subject: [PATCH 2/2] tools/ocaml: Fix stubs the introduction of domain_create.cpupool_id Date: Tue, 17 May 2022 20:41:13 +0100 Message-ID: <20220517194113.2574-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20220517194113.2574-1-andrew.cooper3@citrix.com> References: <20220517194113.2574-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1652816532241100003 Sadly, cpupool IDs are chosen by the caller, not assigned sequentially, so this does need to have a full 32 bits of range. Also leave a BUILD_BUG_ON() to catch more obvious ABI changes in the future. Fixes: 92ea9c54fc81 ("arm/dom0less: assign dom0less guests to cpupools") Signed-off-by: Andrew Cooper Acked-by: Christian Lindig > --- CC: Christian Lindig CC: Edwin T=C3=B6r=C3=B6k CC: Luca Fancellu --- tools/ocaml/libs/xc/xenctrl.ml | 1 + tools/ocaml/libs/xc/xenctrl.mli | 1 + tools/ocaml/libs/xc/xenctrl_stubs.c | 8 +++++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml index 7503031d8f61..8eab6f60eb14 100644 --- a/tools/ocaml/libs/xc/xenctrl.ml +++ b/tools/ocaml/libs/xc/xenctrl.ml @@ -85,6 +85,7 @@ type domctl_create_config =3D max_grant_frames: int; max_maptrack_frames: int; max_grant_version: int; + cpupool_id: int32; arch: arch_domainconfig; } =20 diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.= mli index d1d9c9247afc..d3014a2708d8 100644 --- a/tools/ocaml/libs/xc/xenctrl.mli +++ b/tools/ocaml/libs/xc/xenctrl.mli @@ -77,6 +77,7 @@ type domctl_create_config =3D { max_grant_frames: int; max_maptrack_frames: int; max_grant_version: int; + cpupool_id: int32; arch: arch_domainconfig; } =20 diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenc= trl_stubs.c index 5b4fe72c8dec..513ee142d2a0 100644 --- a/tools/ocaml/libs/xc/xenctrl_stubs.c +++ b/tools/ocaml/libs/xc/xenctrl_stubs.c @@ -189,7 +189,8 @@ CAMLprim value stub_xc_domain_create(value xch, value w= anted_domid, value config #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_ARCH Field(config, 9) +#define VAL_CPUPOOL_ID Field(config, 9) +#define VAL_ARCH Field(config, 10) =20 uint32_t domid =3D Int_val(wanted_domid); int result; @@ -201,6 +202,7 @@ CAMLprim value stub_xc_domain_create(value xch, value w= anted_domid, value config .max_maptrack_frames =3D Int_val(VAL_MAX_MAPTRACK_FRAMES), .grant_opts =3D XEN_DOMCTL_GRANT_version(Int_val(VAL_MAX_GRANT_VERSION)), + .cpupool_id =3D Int32_val(VAL_CPUPOOL_ID), }; =20 domain_handle_of_uuid_string(cfg.handle, String_val(VAL_HANDLE)); @@ -225,6 +227,9 @@ CAMLprim value stub_xc_domain_create(value xch, value w= anted_domid, value config case 1: /* X86 - emulation flags in the block */ #if defined(__i386__) || defined(__x86_64__) =20 + /* Quick & dirty check for ABI changes. */ + BUILD_BUG_ON(sizeof(cfg) !=3D 64); + /* Mnemonics for the named fields inside xen_x86_arch_domainconfig= */ #define VAL_EMUL_FLAGS Field(arch_domconfig, 0) =20 @@ -254,6 +259,7 @@ CAMLprim value stub_xc_domain_create(value xch, value w= anted_domid, value config } =20 #undef VAL_ARCH +#undef VAL_CPUPOOL_ID #undef VAL_MAX_GRANT_VERSION #undef VAL_MAX_MAPTRACK_FRAMES #undef VAL_MAX_GRANT_FRAMES --=20 2.11.0