From nobody Tue Nov 26 20:13:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1704628584; cv=none; d=zohomail.com; s=zohoarc; b=nxgYMq4i7tqhUpVCujAxP+4hgvyX5nqAwQDABZc5070mPvDApp5WXsAOdER9Sbm8tpFf5+21NQYZOvFmIbqOiMk0cq7Orne5q+bxjJJixb1Hr8D/lh+/ChQEiYLysZURCC2DjZP2Tuh5D4ydbQzuq5hrvzBbpPRxDwuj4HNXpx8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704628584; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4uRq7C9ZUE1eAcpVbzP7nNiWmwJQwxB+eLzHwmIPY48=; b=FULqzAqWQCUmjLcSxy6zZcervXfj0Ky6N6a9ltojCil5DFdViCdWIekMpic/qpP6uYpnRLVDMFA80tL7yev9rHY9PlxJvKKIgLtOJHNvuvnCw3B+b4599t+sZciH6zGzzS5XlDgbYBVu9VKPTrOuy0DsnC9US79MW5jeY2Qbz+A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170462858408774.01602978487233; Sun, 7 Jan 2024 03:56:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rMRkX-0001c3-8p; Sun, 07 Jan 2024 06:55:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rMRkW-0001bm-HY for qemu-devel@nongnu.org; Sun, 07 Jan 2024 06:55:28 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rMRkR-0004oe-Nc for qemu-devel@nongnu.org; Sun, 07 Jan 2024 06:55:28 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1d3e6c86868so8163365ad.1 for ; Sun, 07 Jan 2024 03:53:23 -0800 (PST) Received: from localhost.localdomain ([171.216.79.156]) by smtp.gmail.com with ESMTPSA id x5-20020a1709027c0500b001d4ea1b6a2csm4082694pll.32.2024.01.07.03.53.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jan 2024 03:53:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smartx-com.20230601.gappssmtp.com; s=20230601; t=1704628402; x=1705233202; darn=nongnu.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=4uRq7C9ZUE1eAcpVbzP7nNiWmwJQwxB+eLzHwmIPY48=; b=yUYulyVlhFjl9IQ2ooRgwS1VMBe7Jhxv/AAFSQjZ30c2Oid//3qKJLClmY115uDpvX HxAiaSWo2Ufsr1ylhoKJO4/R5/lN3RJk0lHHQMfd3D8SwUZF+ASDPGh6zxhRrXZfnDV+ xCAIdwVDBKmhpBUj0QvWIdobXaKnHsVVLmkZC9wCJpkWtlyQmPN4WHiTbY8RIrnW55Ze 5jPft+IsDIFGIWAW2+NIspmMjxirw9cAe5zdSWuxnSjzCVeVVDv7kiN23IL0QObeK/Dj bZuIlBSrLJjZ7mzrOvEuDgcjJP5zVNK92vwd1GMH4DCzLuAj07AiDRv3924HSWj2TSXf I49w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704628402; x=1705233202; 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=4uRq7C9ZUE1eAcpVbzP7nNiWmwJQwxB+eLzHwmIPY48=; b=VU7NP7lcWW86ZNRNenVaKBrr8Faw596CaunoeBivWn5J9/6/teesL6atHwxyLHHngW Js8BFpwqr67MVh0KDpsfx0MYLfFVoslaLwTPPkMH0ry0U8FkPhtrQsarIGpnE/3GhQzC lKEb9RBZCJoCDNDdHD6NpcQ5/DPfiPzm5NA5RVhMQNFh6ZeYKtt/kDvF6Ie+Ozgk2mBY pI108IiduSev59PXBHS4fbyJdv2BgiAcqvOcUNV36HqCKEZgSYiXfv0HD/DrrdvSPvSF lLMaE3jM+Inb5ZrfNcStv+4W9BZFmEG4+mD7EZPJvYmi16PiEeK2akq09YYJ9jjxGj2T kSYw== X-Gm-Message-State: AOJu0YyNhH/NLRaHikxxBy+ePRpHuxfcpU1x4bjq8gxrLP0K4FyhIGit O9vrv08MZ+2o1ZXCsTtDAmaOXg+/uY9KkPMamZmEeY5v1PY7xQ== X-Google-Smtp-Source: AGHT+IHdIfgeYZEiF3tTWfQsB1ak1gzEwGCgnN1O1v57XzzETiid0mUahyz1as9XLGZV4OIdOngZUQ== X-Received: by 2002:a17:902:b489:b0:1d4:9c06:1807 with SMTP id y9-20020a170902b48900b001d49c061807mr2254254plr.47.1704628401535; Sun, 07 Jan 2024 03:53:21 -0800 (PST) From: Hyman Huang To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Marcelo Tosatti , yong.huang@smartx.com Subject: [PATCH v2 1/2] i386/sev: Sort the error message Date: Sun, 7 Jan 2024 19:53:10 +0800 Message-Id: X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::630; envelope-from=yong.huang@smartx.com; helo=mail-pl1-x630.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @smartx-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1704628585964100004 Content-Type: text/plain; charset="utf-8" Prior to giving the caller the return number(in the next commit), sorting the error message: 1. report the error number on the ram_block_discard_disable failure path 2. report the error number on the syscall "open" failure path 3. report EINVAL when a prerequisite check fails or the command line is invalid Signed-off-by: Hyman Huang --- target/i386/sev.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/target/i386/sev.c b/target/i386/sev.c index 9a71246682..96eff73001 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -923,7 +923,7 @@ int sev_kvm_init(ConfidentialGuestSupport *cgs, Error *= *errp) ret =3D ram_block_discard_disable(true); if (ret) { error_report("%s: cannot disable RAM discard", __func__); - return -1; + return ret; } =20 sev_guest =3D sev; @@ -940,6 +940,7 @@ int sev_kvm_init(ConfidentialGuestSupport *cgs, Error *= *errp) if (host_cbitpos !=3D sev->cbitpos) { error_setg(errp, "%s: cbitpos check failed, host '%d' requested '%= d'", __func__, host_cbitpos, sev->cbitpos); + ret =3D -EINVAL; goto err; } =20 @@ -952,11 +953,12 @@ int sev_kvm_init(ConfidentialGuestSupport *cgs, Error= **errp) error_setg(errp, "%s: reduced_phys_bits check failed," " it should be in the range of 1 to 63, requested '%d'", __func__, sev->reduced_phys_bits); + ret =3D -EINVAL; goto err; } =20 devname =3D object_property_get_str(OBJECT(sev), "sev-device", NULL); - sev->sev_fd =3D open(devname, O_RDWR); + ret =3D sev->sev_fd =3D open(devname, O_RDWR); if (sev->sev_fd < 0) { error_setg(errp, "%s: Failed to open %s '%s'", __func__, devname, strerror(errno)); @@ -981,6 +983,7 @@ int sev_kvm_init(ConfidentialGuestSupport *cgs, Error *= *errp) if (!kvm_kernel_irqchip_allowed()) { error_report("%s: SEV-ES guests require in-kernel irqchip supp= ort", __func__); + ret =3D -EINVAL; goto err; } =20 @@ -988,6 +991,7 @@ int sev_kvm_init(ConfidentialGuestSupport *cgs, Error *= *errp) error_report("%s: guest policy requires SEV-ES, but " "host SEV-ES support unavailable", __func__); + ret =3D -EINVAL; goto err; } cmd =3D KVM_SEV_ES_INIT; --=20 2.39.1 From nobody Tue Nov 26 20:13:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1704628570; cv=none; d=zohomail.com; s=zohoarc; b=JsJG2qHxj7eVTAp1aIxUyyChrPALTmpjGeeXcdi9c7y3wgVXuyiWtFXqV9R/82m1ZKdYpWShai4dlTPHK3OgzhoWbMzSKYB+VWGK++6fDKGNRH+ww5gC4TS9KeCoD45y/mcGd0wj1P/VGuaSLLqPqp16v6nfbRyaOnijyJV04es= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704628570; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wfCEURHfoJYyEJ96UVfChxnBswBuLiHx6tLxG6w0IME=; b=LvBFE6mL6o6l5WAJOpBnEF4o8/sGDQ7q95JDjHhRl2ASM5+kmv0FATPFJg/6kiqNM8oMzZlu8txMZ2hH79LjuFMTojmL3eL2CZFfWsRLcwnSLTJ77nFct7/K7Fops0skoakBzrXUu2Mh2lGvAV4XF81hp6yXR8gYzNqg9+RCFko= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704628570715584.7352374316982; Sun, 7 Jan 2024 03:56:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rMRkX-0001cB-EI; Sun, 07 Jan 2024 06:55:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rMRkW-0001ba-AL for qemu-devel@nongnu.org; Sun, 07 Jan 2024 06:55:28 -0500 Received: from mail-il1-x129.google.com ([2607:f8b0:4864:20::129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rMRkU-0004oo-QD for qemu-devel@nongnu.org; Sun, 07 Jan 2024 06:55:28 -0500 Received: by mail-il1-x129.google.com with SMTP id e9e14a558f8ab-3606f507efeso6578895ab.3 for ; Sun, 07 Jan 2024 03:53:26 -0800 (PST) Received: from localhost.localdomain ([171.216.79.156]) by smtp.gmail.com with ESMTPSA id x5-20020a1709027c0500b001d4ea1b6a2csm4082694pll.32.2024.01.07.03.53.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jan 2024 03:53:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smartx-com.20230601.gappssmtp.com; s=20230601; t=1704628405; x=1705233205; darn=nongnu.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=wfCEURHfoJYyEJ96UVfChxnBswBuLiHx6tLxG6w0IME=; b=bxVFomnYV3FcC2Dq69Ar9+jikZlqYC5fh/XhSbj0cgEvNXXCIKpLUfZECGq2ZExJk+ e5EIPv/HlIZNfY6fpd7fgh6L2UJXO1xoy3Qc7SzirUKnG2Au9kPrP3XByG+BjlnZj5Sv 3I2RzmKuVHDQ+TpL+FpPRUlzjOj0IVzjKABBzHZ/0G8e0WASdxteksiUAt/QNuvgddht xgh2kS2S3VJJbXxJ3f8aIcwIykTrifFlRnH0X9NHonoc9b8mZ5QmtTDSK55bO6ryGj+w VgZijlgOHEfCLs4Lb/4Ukn6IEEWzMdpUjwSly3PM+3vPZIX7yUynMyRywy6bNtUdDtcg Be0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704628405; x=1705233205; 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=wfCEURHfoJYyEJ96UVfChxnBswBuLiHx6tLxG6w0IME=; b=bGX8niGCVF3eDUF5zbikSX3QIy6f/5QtKESOoQA7r3PuG38HgTtNnP9YsoDNBA19fT ZpYh+LMYzGFiF2w8voAPjqfIvQ9yaa1fg2O1u7Bw/Un6B2kW0kglDg7pU4L5WYrSIi09 fetMqBexQ/uSIL+CYjjdl1XxPSD/lw5UhTmhWZm17+9bG0YuUyvc/+sR+7j2XPs6bFBi UDyp1wRMI/tyVHMDkEouW2CoJ7u37YjWq457MnBDG7Mp1VHqVUI+VnB3YtmesKbAqtom zHo+OXjwuP/RNonCsiOp30gFQW0dlNjJIClMdrLUlT0VQYZlmuqqE7HlZbcoOj6Pq8Dt Lg3A== X-Gm-Message-State: AOJu0YylHOWmEjXe6Gq2oPRW++FBVHHDcnhK4VSGqjVPXISOvASK4eAO ReWm1ibMgLwwcmEX+Ul/uKXPREnCroRjRO/MnuRd9vawLHwI0w== X-Google-Smtp-Source: AGHT+IFfUNYsnm2Bn8zu/P/Vjm4bVutG//muG7PXoQMluMBQb0PV4u9qT3NkuSBOaayeuZNeCH5OCQ== X-Received: by 2002:a05:6e02:19c5:b0:35d:6121:3794 with SMTP id r5-20020a056e0219c500b0035d61213794mr4215127ill.54.1704628405012; Sun, 07 Jan 2024 03:53:25 -0800 (PST) From: Hyman Huang To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Marcelo Tosatti , yong.huang@smartx.com Subject: [PATCH v2 2/2] i386/sev: Nitpick at the error message's output Date: Sun, 7 Jan 2024 19:53:11 +0800 Message-Id: X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::129; envelope-from=yong.huang@smartx.com; helo=mail-il1-x129.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @smartx-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1704628571924100001 The incorrect error message was produced as a result of the return number being disregarded on the sev_kvm_init failure path. For instance, when a user's failure to launch a SEV guest is caused by an incorrect IOCTL, the following message is reported: kvm: sev_kvm_init: failed to initialize ret=3D-25 fw_error=3D0 kvm: failed to initialize kvm: Operation not permitted While the error message's accurate output should be: kvm: sev_kvm_init: failed to initialize ret=3D-25 fw_error=3D0 kvm: failed to initialize kvm: Inappropriate ioctl for device Fix this by returning the return number directly on the failure path. Signed-off-by: Hyman Huang Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: --- target/i386/sev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/sev.c b/target/i386/sev.c index 96eff73001..3fef8cf163 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -1023,7 +1023,7 @@ int sev_kvm_init(ConfidentialGuestSupport *cgs, Error= **errp) err: sev_guest =3D NULL; ram_block_discard_disable(false); - return -1; + return ret; } =20 int --=20 2.39.1