From patchwork Fri Sep 30 11:38:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 610937 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp1469329pvb; Fri, 30 Sep 2022 04:42:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4bxLScp1/+lpr39VQPRHj3A8UjUOPRI3iaAzZt9vnIqm7vZ/CBAAsHOXc4zqjwyeu638pf X-Received: by 2002:a05:622a:18a3:b0:35b:af14:401e with SMTP id v35-20020a05622a18a300b0035baf14401emr6116910qtc.200.1664538143849; Fri, 30 Sep 2022 04:42:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664538143; cv=none; d=google.com; s=arc-20160816; b=YbsZhTIkAbkWB+3BlG5BDN/F2NkgEJZ2HlulIJT/Zvlzd4ZCOEIWdS96QTUFi8aUNZ p+2m0W4IrEpD5eNOtZ6PF57nNWkr75XIxU4dk9ntR7wDSaVK3vpsByaXGcKifuqv5rML R61926dB/humvd8000T/TBRIooYOhWxUyzKu9BPAfpYnfPGH2hH+kQ8F4oB3BpwvnGN7 Ja7Izuiz1tZvJqIlIPwFMCfxFUQFdfFYABWLauah0Fw8tePsY09Y4udBCPmkLwcPpbJ3 5ilziImBrSdSsuWYft4nVu15WI3mmg+zPDkFA0ySYlywp/TYUPzyTG/Na6ZNXVrAnBKT hpgQ== 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=+4aLiqQ8KIdEY41na51qPEkuVYOkht+mGBrTF+/kit8=; b=Lc77m1phecVnnLPoFXRWOUIk7v59q8ubIDIDlPbfVUfy308g6v99TboWxJ72sdMjMy CfBr++WDDcpE0QdEkObQpTakBvweRNjYmbHebedM2Mrsu2xA/SAuMcm/1EKDmW6GwwNO 8tobdNeVbwuGdrcUN5M2xK5MU9gsC4jP7YpvD0UN0fkFciQ4i/GgDyCCEU+/L6zDPqwH 8sphEl+i2UPhHi4PuuBTvGYbIgOvp7Lbtm+HUXVfa6XOFZ2mEu0ht3mVGYWTRjCKa5RK C9UYANeLfy9PvM0NCOh7zgyYP3AtDCO+DxUhhTdBvBlLlJHzuDAT0hTpWwHl6VgC6w+X UtUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="vRRh/bEA"; 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 jl8-20020ad45e88000000b004aca1197e25si1082973qvb.32.2022.09.30.04.42.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Sep 2022 04:42:23 -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="vRRh/bEA"; 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]:59272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oeEPP-0002HI-Cw for patch@linaro.org; Fri, 30 Sep 2022 07:42:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52382) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oeELe-0002Fo-H0 for qemu-devel@nongnu.org; Fri, 30 Sep 2022 07:38:30 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:46058) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oeELc-0002kD-P0 for qemu-devel@nongnu.org; Fri, 30 Sep 2022 07:38:30 -0400 Received: by mail-wr1-x436.google.com with SMTP id n10so6403190wrw.12 for ; Fri, 30 Sep 2022 04:38:28 -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=+4aLiqQ8KIdEY41na51qPEkuVYOkht+mGBrTF+/kit8=; b=vRRh/bEAqiVtM18ZODiv3g6JpS1zfJwcjGOo06AuehB4ry1q17OUfSChfoow7Pejn0 lP3N0PCxCDNe2ucj7ZCrQ0zHVIEXwzpGjBPqRmg0iR8sEJer3qWU25DJLKMrhq7PIc++ f/BMacGnWdHziSEFT1RsTC27y4ZHnvTrXEmA+RCVBUtdQcyya30SaEPtlN+wKWhkzYJ0 WbKUdHnN63ZegrG+eA4GHxTLYRF1Mb8BxkBohrup4KI/Jnn0KLso6FSptP72XoI9fDwV OLEmb1VD8PFNklasHYZY12yhpGYbYFi8c6B6rJpZWjbxSBQfw9Th1tfvpJrt0mHeYu3m JN0Q== 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=+4aLiqQ8KIdEY41na51qPEkuVYOkht+mGBrTF+/kit8=; b=gl6dkT4odxjMxSJUWWGRdT8hgAWyTbpVDPqvbPognO4FoINDHDIIi267hs+g4rhCCS 0qhdEIHx9Mxp2ENgAMGALkd5l9GCdT8BXU+56f9jO7FVHZCKpp3Enes/FK2hnFbuEybC 1Iwd9/4dlcYvI5B4wT14HugxS0nTihN2oZbMYKz9GyCuj9h+imRP2a+fnl2s8jd2dNWO gp0koY2plgCM7DMLORbD/ETPDHtAW1V2O551g5WcwkLWbGVhkDyy2E7PNdycpUV0Rfj8 jnW78MB+uCPuqrnfEAr1YrQKK8+8BmMvUXC+sA2qFYz2hysXdD8Keg7z4hMJyhxoEo/q 1n+A== X-Gm-Message-State: ACrzQf1x7Lsvd4PtzHhpcRglE/xly2+I4mesY9s4++uTTgbF/hzvZKFq rAH2WklzaONlwTE/4B96OMewAQ== X-Received: by 2002:a5d:584e:0:b0:22b:724:11c0 with SMTP id i14-20020a5d584e000000b0022b072411c0mr5287048wrf.225.1664537907088; Fri, 30 Sep 2022 04:38:27 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id y9-20020a5d4ac9000000b0021badf3cb26sm2150008wrs.63.2022.09.30.04.38.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Sep 2022 04:38:26 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Vitaly Chikunov , Marc Zyngier , Eric Auger , Paolo Bonzini Subject: [PATCH v3] target/arm/kvm: Retry KVM_CREATE_VM call if it fails EINTR Date: Fri, 30 Sep 2022 12:38:24 +0100 Message-Id: <20220930113824.1933293-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::436; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x436.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: Vitaly Chikunov Acked-by: Marc Zyngier Reviewed-by: Eric Auger --- 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". v2: correctly check for -1 and errno is EINTR... v3: really correctly check errno. This time for sure! --- 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..1e4de9b42e3 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 == -1 && errno == EINTR); if (vmfd < 0) { goto err; }