From patchwork Mon Sep 26 13:36:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 609311 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp1864368pvb; Mon, 26 Sep 2022 06:43:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5j519GnuaBz4S6bdWU2sDhqmBVIRW6OLN7P0hxEfd0JcUaF9kelAFbuh3sztTblKOuM4MU X-Received: by 2002:a05:622a:1a86:b0:35b:b48d:3f37 with SMTP id s6-20020a05622a1a8600b0035bb48d3f37mr18032301qtc.310.1664199837209; Mon, 26 Sep 2022 06:43:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664199837; cv=none; d=google.com; s=arc-20160816; b=t+iraaD1MLR5ghRktnPsty3vZnzYMaZYb+5n2iTsY/paoM6TO0uEP2frHNKnhMPJHb 7n6TuneE/kfsnvIy9Y07uqe8UGw5qboyyUj+6jWHJpKWFhGR/h3iLaikQ6SNWsezIIsa 8tcVJ3x9QIH7SisWIdq+nemxjLM8i24LXckp1PH63VK95NRHglFQpKvStJ53Nq7yblhV SFnXt0AfaPAZoECzO1dsFqXSGosRl6qDw+CUXlbfyLP6GKBVpdu1MmRjkiFZnKs5+l5o 7Q6EyJhOg/6S+g2yKQE6AgfIel9fVrMnogKECQJ3tnCelxSs+GLmSuhOfZ6nPLpXsm14 qmIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=32Qjyb7u8FfjYe0CuySFLQoFDnmi7EIBx8CauNR3+IQ=; b=lMhortYJZaCGhuCS13ZhWogDFwZUKcetwjSILXl+6rRXJc50lL+xqmdoOYQwE+i9jz f7u30g1ZkvQsJsc6EAwMRcJ9FpvEYgxjhwpGmKvecZRsw7ximXJT025wHtliuh+6bESg Ae+Rp9cSAKMOfMutH2h8XIrcQokGipk/2z3WJlRUW2C7nxegeVAnnxD0n2bWwrQtZq91 6+ExvLMqB51FpcGXDIqoto9uOzZTqQxoRjXY+3ZHGc4cLhYYqtVDGGGgsGKI5QWyzkFH 7W3ymfcoplVWyZL4by+IKez3F+eGHQy2+yvqiWnmsdDsrrRXKK/aa9oJyRNw9gDDGL1d NxEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MFc0hMZ5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i20-20020a05620a249400b006cdf5daf139si8511774qkn.694.2022.09.26.06.43.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Sep 2022 06:43:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MFc0hMZ5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:54160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocoOq-00079d-Oo for patch@linaro.org; Mon, 26 Sep 2022 09:43:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocoI0-0007QP-G6 for qemu-devel@nongnu.org; Mon, 26 Sep 2022 09:36:53 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:38792) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocoHx-0005HN-Af for qemu-devel@nongnu.org; Mon, 26 Sep 2022 09:36:51 -0400 Received: by mail-wm1-x32d.google.com with SMTP id c192-20020a1c35c9000000b003b51339d350so5105235wma.3 for ; Mon, 26 Sep 2022 06:36:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=32Qjyb7u8FfjYe0CuySFLQoFDnmi7EIBx8CauNR3+IQ=; b=MFc0hMZ5VBGWRTwknGOwpuzKeR3pmdTsEoGaU5R9iz7v2ZaRGogWZp3knqcvDUV8d2 TYI0V1O9UuDYbsXli38qNubRy8m8wu15pcDRr5gnhV8RKpfKjP53RCFG54zyFD7jWi/5 b0wySMl8YFWuZzIj040vab61fYk08BgflF8ZIOGoy+R0kTjmIlXZClNQ4JkiT6Ws5mhp L3V7gSg1tmMbiz4ugZe2JSuvGcVdeIZ/wCeUuYSbgseFz+qHxacZvCx1aaVMdoMWgm8l O3LKLHiCMk64ZeY/bJIExZMpVLDErfq2s2wb6A5A3UC1Du1qtsKpvOUQx2VI0TsVDTaE wh9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=32Qjyb7u8FfjYe0CuySFLQoFDnmi7EIBx8CauNR3+IQ=; b=RjEBPiGPCLETfxmug297wHKZsjrrNSmN7Y3YjOmI73gIq9kBBooLbCoKw3vQ+AQdRC rF97g8K1D8Heua6vGrc3ITsPkH4IPUgc4zi0yPXMJfKJaVY1aFjNQDnukso1rORCTumP tbeqAnow0vuS7P5hQXsgQTjimS5oZBphgePLB6rdpiO4TJsCf+/LObQWVCrlr6CmVbu+ h0Lf5nE85RjbDZ+7BFrt748gN5kINnPsETuF0r4Xbj3NAjKHIDAZxQbygD9GpBQUxDUX jRo5pHVyBb9JV78MtIaMF3Dmue5eh0jK8zdtOqfygUbxoE/iGcM1b2x3Ezfh8g1MmIXZ Wrrg== X-Gm-Message-State: ACrzQf0IQbHjRGP9O1vnaMm/2a3A34WyCPCB6+8Y5bHm04CZw+3FbMF/ evNBSCUPY5udUZHY/yqBOnmvCQ== X-Received: by 2002:a05:600c:1d2a:b0:3b4:6e31:92da with SMTP id l42-20020a05600c1d2a00b003b46e3192damr21315738wms.103.1664199407021; Mon, 26 Sep 2022 06:36:47 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id b15-20020a5d40cf000000b00228fa832b7asm14206102wrq.52.2022.09.26.06.36.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 06:36:46 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Vitaly Chikunov , Marc Zyngier , Paolo Bonzini Subject: [PATCH] target/arm/kvm: Retry KVM_CREATE_VM call if it fails EINTR Date: Mon, 26 Sep 2022 14:36:44 +0100 Message-Id: <20220926133644.1345269-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Occasionally the KVM_CREATE_VM ioctl can return EINTR, even though there is no pending signal to be taken. In commit 94ccff13382055 we added a retry-on-EINTR loop to the KVM_CREATE_VM call in the generic KVM code. Adopt the same approach for the use of the ioctl in the Arm-specific KVM code (where we use it to create a scratch VM for probing for various things). For more information, see the mailing list thread: https://lore.kernel.org/qemu-devel/8735e0s1zw.wl-maz@kernel.org/ Reported-by: Vitaly Chikunov Signed-off-by: Peter Maydell Reviewed-by: Eric Auger Acked-by: Marc Zyngier --- The view in the thread seems to be that this is a kernel bug (because in QEMU's case there shouldn't be a signal to be delivered at this point because of our signal handling strategy); so I've adopted the same "just retry-on-EINTR for this specific ioctl" approach that commit 94ccff13 did, rather than, for instance, something wider like "make kvm_ioctl() and friends always retry on EINTR". --- target/arm/kvm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/target/arm/kvm.c b/target/arm/kvm.c index e5c1bd50d29..2982d216176 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -79,7 +79,9 @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try, if (max_vm_pa_size < 0) { max_vm_pa_size = 0; } - vmfd = ioctl(kvmfd, KVM_CREATE_VM, max_vm_pa_size); + do { + vmfd = ioctl(kvmfd, KVM_CREATE_VM, max_vm_pa_size); + } while (vmfd == -EINTR); if (vmfd < 0) { goto err; }