From nobody Thu Nov 21 17:48:56 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=1725040409; cv=none; d=zohomail.com; s=zohoarc; b=GXbiOFq1wjDFrlCFxy6ypXkyLXFS1roycz51UB4VEPQ9FojWMVR2sYomsS3+CKqZ4odd4Vb5/PGiYpVZlmvPwKOBfJKoB/J+yJmDZU57A9yAaNVZzpRKbEfofpgzkhVOQj6A7287R40aJcmfwMn+gQIxj7a1I+Xh+jb6031EnQ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725040409; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iLBjy3jQyg2WrSnoZIIBj/Tgnhve2wb9GQSzOxv16XM=; b=S5/HBeW5ywBvlN9bwtNNHJ6K9/VgX0KCfwFHwRhweyYZbr4uui6mPTfLwG9/JS9V7ZxqYnoKSax8OP9ZrUJhSdM6wt05Y4KnVgpR3FDuG0doWkJBwNVYFbdA7nFd7iPnOtA6/9K7gIAwwyx9evImTMMII9SnoWGeSebUULM6VFc= 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 1725040409809488.9501298082058; Fri, 30 Aug 2024 10:53:29 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.786568.1196154 (Exim 4.92) (envelope-from ) id 1sk5oD-0001g6-9w; Fri, 30 Aug 2024 17:53:17 +0000 Received: by outflank-mailman (output) from mailman id 786568.1196154; Fri, 30 Aug 2024 17:53:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk5oD-0001fz-71; Fri, 30 Aug 2024 17:53:17 +0000 Received: by outflank-mailman (input) for mailman id 786568; Fri, 30 Aug 2024 17:53:15 +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 1sk5oB-0001fr-As for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 17:53:15 +0000 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [2a00:1450:4864:20::636]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ba711939-66f8-11ef-a0b1-8be0dac302b0; Fri, 30 Aug 2024 19:53:13 +0200 (CEST) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a86910caf9cso555690666b.1 for ; Fri, 30 Aug 2024 10:53:13 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8988feb2a3sm239739966b.3.2024.08.30.10.53.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 10:53:11 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ba711939-66f8-11ef-a0b1-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1725040393; x=1725645193; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=iLBjy3jQyg2WrSnoZIIBj/Tgnhve2wb9GQSzOxv16XM=; b=TNybCgAe0QBRRO56b5+vA6AU5rk/Gy62f7kzAAII8w3YkYrJ1cbhwV3Xo1JTA418Lp XTBFvGsd14GyObafQjMXCy3wDu64qvtxmB/bcTteZ6O408XN8gK6GAh/2cLyoXQJkJyy UJW1BXWeRED7oQZCTZikbLa0VVnAKCbz+/AAQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725040393; x=1725645193; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=iLBjy3jQyg2WrSnoZIIBj/Tgnhve2wb9GQSzOxv16XM=; b=s+bNUuroR3d2dhwxQeXUWn8iRtGidCjNBElpfyMc5xTaKBATdBx6+bb/CmbJpUmlWF x4j7GuKPtAHXbOTfGBa374Q/2x6WoDIwPwznOivugczG/17jSajJjFAYrEJYm+2CyPaw hmuvVzD6pOO3N2L18oON6GElkyiYShPLq8q8EYkQxECFBJa3SDEbaRJKA7ZAVxAotpol QeEiejWnz+EF4jfdT2qZREkzIXWGgkP+KkxhiqvC247AXM8b/hXz8XF0bt9UdkcgOLnY BpUzHgDfEadI5cRS1p8avdyXLS90nc/WxzCTZoDZHW8Kwm9xTsDwyk7VZjgAqgCMAElv hIAQ== X-Gm-Message-State: AOJu0YyNxMEz+iRSy2KpqChb2jMbP0/P74S/caO+8D412wzvIWtGaj3W +D5WOqJYRSJatosYTWl/7lEpcClSe2D2Mhj+UYsrp3pMKy64TzwwdL3Wps1lA7I0PKlE+wD7WUs r X-Google-Smtp-Source: AGHT+IEc+PBwEUC87ER5KaT6r3CPMvdWEEhenPmCO1InpZBVYj2ppc+KV97HFABgF08k7L7IVEa6MA== X-Received: by 2002:a17:906:565a:b0:a89:b829:7598 with SMTP id a640c23a62f3a-a89b8297622mr60152566b.12.1725040392217; Fri, 30 Aug 2024 10:53:12 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Christian Lindig , David Scott , =?UTF-8?q?Edwin=20T=C3=B6r=C3=B6k?= , Rob Hoes , Andrii Sultanov Subject: [PATCH] tools/ocaml/xc: Drop the GC lock for all hypercalls Date: Fri, 30 Aug 2024 18:53:09 +0100 Message-Id: <20240830175309.2854442-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.2 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: 1725040410999116600 We should be doing this unilaterally. Signed-off-by: Andrew Cooper Acked-by: Christian Lindig --- CC: Christian Lindig CC: David Scott CC: Edwin T=C3=B6r=C3=B6k CC: Rob Hoes CC: Andrii Sultanov Also pulled out of a larger cleanup series. --- tools/ocaml/libs/xc/xenctrl_stubs.c | 63 +++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenc= trl_stubs.c index c78191f95abc..20487b21008f 100644 --- a/tools/ocaml/libs/xc/xenctrl_stubs.c +++ b/tools/ocaml/libs/xc/xenctrl_stubs.c @@ -312,7 +312,10 @@ CAMLprim value stub_xc_domain_max_vcpus(value xch_val,= value domid, xc_interface *xch =3D xch_of_val(xch_val); int r; =20 + caml_enter_blocking_section(); r =3D xc_domain_max_vcpus(xch, Int_val(domid), Int_val(max_vcpus)); + caml_leave_blocking_section(); + if (r) failwith_xc(xch); =20 @@ -329,7 +332,10 @@ value stub_xc_domain_sethandle(value xch_val, value do= mid, value handle) =20 domain_handle_of_uuid_string(h, String_val(handle)); =20 + caml_enter_blocking_section(); i =3D xc_domain_sethandle(xch, Int_val(domid), h); + caml_leave_blocking_section(); + if (i) failwith_xc(xch); =20 @@ -391,7 +397,10 @@ CAMLprim value stub_xc_domain_shutdown(value xch_val, = value domid, value reason) xc_interface *xch =3D xch_of_val(xch_val); int ret; =20 + caml_enter_blocking_section(); ret =3D xc_domain_shutdown(xch, Int_val(domid), Int_val(reason)); + caml_leave_blocking_section(); + if (ret < 0) failwith_xc(xch); =20 @@ -503,7 +512,10 @@ CAMLprim value stub_xc_domain_getinfo(value xch_val, v= alue domid) xc_domaininfo_t info; int ret; =20 + caml_enter_blocking_section(); ret =3D xc_domain_getinfo_single(xch, Int_val(domid), &info); + caml_leave_blocking_section(); + if (ret < 0) failwith_xc(xch); =20 @@ -546,7 +558,10 @@ CAMLprim value stub_xc_vcpu_context_get(value xch_val,= value domid, int ret; vcpu_guest_context_any_t ctxt; =20 + caml_enter_blocking_section(); ret =3D xc_vcpu_getcontext(xch, Int_val(domid), Int_val(cpu), &ctxt); + caml_leave_blocking_section(); + if ( ret < 0 ) failwith_xc(xch); =20 @@ -584,10 +599,14 @@ CAMLprim value stub_xc_vcpu_setaffinity(value xch_val= , value domid, if (Bool_val(Field(cpumap, i))) c_cpumap[i/8] |=3D 1 << (i&7); } + + caml_enter_blocking_section(); retval =3D xc_vcpu_setaffinity(xch, Int_val(domid), Int_val(vcpu), c_cpumap, NULL, XEN_VCPUAFFINITY_HARD); + caml_leave_blocking_section(); + free(c_cpumap); =20 if (retval < 0) @@ -612,10 +631,13 @@ CAMLprim value stub_xc_vcpu_getaffinity(value xch_val= , value domid, if (c_cpumap =3D=3D NULL) failwith_xc(xch); =20 + caml_enter_blocking_section(); retval =3D xc_vcpu_getaffinity(xch, Int_val(domid), Int_val(vcpu), c_cpumap, NULL, XEN_VCPUAFFINITY_HARD); + caml_leave_blocking_section(); + if (retval < 0) { free(c_cpumap); failwith_xc(xch); @@ -639,9 +661,13 @@ CAMLprim value stub_xc_sched_id(value xch_val) { CAMLparam1(xch_val); xc_interface *xch =3D xch_of_val(xch_val); - int sched_id; + int ret, sched_id; + + caml_enter_blocking_section(); + ret =3D xc_sched_id(xch, &sched_id); + caml_leave_blocking_section(); =20 - if (xc_sched_id(xch, &sched_id)) + if (ret) failwith_xc(xch); =20 CAMLreturn(Val_int(sched_id)); @@ -674,7 +700,10 @@ CAMLprim value stub_xc_evtchn_reset(value xch_val, val= ue domid) xc_interface *xch =3D xch_of_val(xch_val); int r; =20 + caml_enter_blocking_section(); r =3D xc_evtchn_reset(xch, Int_val(domid)); + caml_leave_blocking_section(); + if (r < 0) failwith_xc(xch); CAMLreturn(Val_unit); @@ -811,7 +840,10 @@ CAMLprim value stub_xc_send_debug_keys(value xch_val, = value keys) xc_interface *xch =3D xch_of_val(xch_val); int r; =20 + caml_enter_blocking_section(); r =3D xc_send_debug_keys(xch, String_val(keys)); + caml_leave_blocking_section(); + if (r) failwith_xc(xch); CAMLreturn(Val_unit); @@ -952,7 +984,11 @@ CAMLprim value stub_xc_domain_set_memmap_limit(value x= ch_val, value domid, int retval; =20 v =3D Int64_val(map_limitkb); + + caml_enter_blocking_section(); retval =3D xc_domain_set_memmap_limit(xch, Int_val(domid), v); + caml_leave_blocking_section(); + if (retval) failwith_xc(xch); =20 @@ -1203,8 +1239,11 @@ CAMLprim value stub_xc_domain_ioport_permission(valu= e xch_val, value domid, c_nr_ports =3D Int_val(nr_ports); c_allow =3D Bool_val(allow); =20 + caml_enter_blocking_section(); ret =3D xc_domain_ioport_permission(xch, Int_val(domid), c_start_port, c_nr_ports, c_allow); + caml_leave_blocking_section(); + if (ret < 0) failwith_xc(xch); =20 @@ -1225,8 +1264,11 @@ CAMLprim value stub_xc_domain_iomem_permission(value= xch_val, value domid, c_nr_pfns =3D Nativeint_val(nr_pfns); c_allow =3D Bool_val(allow); =20 + caml_enter_blocking_section(); ret =3D xc_domain_iomem_permission(xch, Int_val(domid), c_start_pfn, c_nr_pfns, c_allow); + caml_leave_blocking_section(); + if (ret < 0) failwith_xc(xch); =20 @@ -1245,8 +1287,11 @@ CAMLprim value stub_xc_domain_irq_permission(value x= ch_val, value domid, c_pirq =3D Int_val(pirq); c_allow =3D Bool_val(allow); =20 + caml_enter_blocking_section(); ret =3D xc_domain_irq_permission(xch, Int_val(domid), c_pirq, c_allow); + caml_leave_blocking_section(); + if (ret < 0) failwith_xc(xch); =20 @@ -1309,7 +1354,9 @@ CAMLprim value stub_xc_domain_test_assign_device(valu= e xch_val, value domid, val func =3D Int_val(Field(desc, 3)); sbdf =3D encode_sbdf(domain, bus, dev, func); =20 + caml_enter_blocking_section(); ret =3D xc_test_assign_device(xch, Int_val(domid), sbdf); + caml_leave_blocking_section(); =20 CAMLreturn(Val_bool(ret =3D=3D 0)); } @@ -1328,8 +1375,10 @@ CAMLprim value stub_xc_domain_assign_device(value xc= h_val, value domid, value de func =3D Int_val(Field(desc, 3)); sbdf =3D encode_sbdf(domain, bus, dev, func); =20 + caml_enter_blocking_section(); ret =3D xc_assign_device(xch, Int_val(domid), sbdf, XEN_DOMCTL_DEV_RDM_RELAXED); + caml_leave_blocking_section(); =20 if (ret < 0) failwith_xc(xch); @@ -1350,7 +1399,9 @@ CAMLprim value stub_xc_domain_deassign_device(value x= ch_val, value domid, value func =3D Int_val(Field(desc, 3)); sbdf =3D encode_sbdf(domain, bus, dev, func); =20 + caml_enter_blocking_section(); ret =3D xc_deassign_device(xch, Int_val(domid), sbdf); + caml_leave_blocking_section(); =20 if (ret < 0) failwith_xc(xch); @@ -1379,8 +1430,11 @@ CAMLprim value stub_xc_get_cpu_featureset(value xch_= val, value idx) /* To/from hypervisor to retrieve actual featureset */ uint32_t fs[fs_len], len =3D fs_len; unsigned int i; + int ret; =20 - int ret =3D xc_get_cpu_featureset(xch, Int_val(idx), &len, fs); + caml_enter_blocking_section(); + ret =3D xc_get_cpu_featureset(xch, Int_val(idx), &len, fs); + caml_leave_blocking_section(); =20 if (ret) failwith_xc(xch); @@ -1403,7 +1457,10 @@ CAMLprim value stub_xc_watchdog(value xch_val, value= domid, value timeout) int ret; unsigned int c_timeout =3D Int32_val(timeout); =20 + caml_enter_blocking_section(); ret =3D xc_watchdog(xch, Int_val(domid), c_timeout); + caml_leave_blocking_section(); + if (ret < 0) failwith_xc(xch); =20 --=20 2.39.2