From patchwork Sat Dec 17 15:24:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 634849 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp1414102pvb; Sat, 17 Dec 2022 07:27:02 -0800 (PST) X-Google-Smtp-Source: AMrXdXuBa0JQDTeu+ohTi/Mmq56Ry9LKEkgJflqluXszwS7gIZLSZKwqoGNhC73ApwJkzkcVcwe9 X-Received: by 2002:ac8:4743:0:b0:3a9:6b96:f14b with SMTP id k3-20020ac84743000000b003a96b96f14bmr12747256qtp.38.1671290822054; Sat, 17 Dec 2022 07:27:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671290822; cv=none; d=google.com; s=arc-20160816; b=TgOSneMYTQ/IA33+W2Mfp9TpfWHRGIAK97f/7lIn2PjdPbv8wvbQ7g/TewFm6mQ97Y HPR3h6zroqBTH3Wb8w0aR2Gd1I8V3lvkrdN/RnlqOvDxCkF04H8TlonkOMlMa2NM9n6D SfLoLC447/y4VK8Nmzm1b3IkaqqyUwxBiFs45mLWb4jnWeYEGKGcuA299nqbx8K8FgmA sI4V4qpFUS6LOw/C/CB/s4Klnqd2g5EYuYDHtxBuoAHfNFurnayxJq5uG5PZYtjZfjBq +xigMWDSxr4nJ0CXFluTlXqW2qUZlTzKuyirU36KUDJIyaC2jJCo5Pb6xZKzl7UQ1YSA PxXw== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Kw1OjQ5bJTHVjNVBcrbAjUuHpYpt+dRXG1ISohyf01M=; b=KHc4c/04+d0DseIqtD/uw4PS46w0TJgPmMyfcaYAw6sC24yQBTf6XsHdMUh5ignWzh DxvOSb/tOW1wNyDYZrwOQOtXlqDOh2ie9waQkM1f6YnieS9jGpVjUfPWfvNO332ItpLm +kcwwQKPIudSNrBl5vdC5Z7FC7NXxU+99c2TMeonzPanNDOz+tSO90tSc4JcJbBFtvQm nPvNDH3w4oXnkBfoSyP9y5NWzi94Kqu+m3zpyO/3KVdSk4j6QAmVHvqwuIM2O++a+sNu gjSeEy5aL2Vwp4qnF9S7DXpjDSGwNINb3ITumwBv4/EwRRvxur0rTJuq6sGH8P2puyaL vlfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Di4wYeCN; 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 d17-20020ac86691000000b003a5504674e8si163720qtp.278.2022.12.17.07.27.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 17 Dec 2022 07:27:02 -0800 (PST) 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=Di4wYeCN; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p6Z3q-0003PD-Nn; Sat, 17 Dec 2022 10:25:14 -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 1p6Z3o-0003Of-Uv for qemu-devel@nongnu.org; Sat, 17 Dec 2022 10:25:12 -0500 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p6Z3n-0005OV-8H for qemu-devel@nongnu.org; Sat, 17 Dec 2022 10:25:12 -0500 Received: by mail-ej1-x62b.google.com with SMTP id gh17so12537579ejb.6 for ; Sat, 17 Dec 2022 07:25:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=Kw1OjQ5bJTHVjNVBcrbAjUuHpYpt+dRXG1ISohyf01M=; b=Di4wYeCNcUyETg+kjFT1GZF088S+YKhSQ/hQikA498Yoh2hFhvDjzBvfVBhaaBNeDY aWXeupZsRnSvD1VpmMCnyu51LaHvwMHSPAQ46CtM5GqiEc1wAbK4SGYvfJahnZ3xkGWz wHqQxaVmvKsFOv2A/JRHmhRWGptfwRMwYui+mVLD1j9lRkJVS2ibrTbqCPxpqQeAEAD/ fZOp/H+WJIRux5XUm3UXjsggcWtIM4FXCO8HrOhspWqtwbHURozpvi2+k8rOZ5DFNdrX 5C55tXi7nSm9FG0o5wAx+09B5VBgRrVxKKzAEuf4FMBNGVWp6o9D1jOUfZc51/WltiwU jnLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Kw1OjQ5bJTHVjNVBcrbAjUuHpYpt+dRXG1ISohyf01M=; b=gUvC89mOX8es0hhI6bbTlRY7PPRNlBJRFb5ZxbphORAlkLhUZFfhEKPn5rPOPcPtHZ mfDE0droFv+nm7KklBJPHahSy4Ja9DfomwkT0qCvz24f+ALsQFVvE3uawR5TngwiwjSU q2IJO9CTyJdb6FLzoBSjrthhUySxrSb8Ygw5S1aS0KQvyxExiQD75XBALUHmWmGRkQJp ERAP1Xc6IyFE3BvL5pQyWs8mg/oU6qLUS4LpSTsghhev6/7IK11HVtlvVP4vs+fsISPA QYcJy9t8lx1fEWW7QUB3GaqKuoyuF5WVpXGzZ7h9I68emCT92KB6hPThJJFPmV10WzDs hjtA== X-Gm-Message-State: AFqh2kr7Jv5vU6ddKEHPPsAx+7iwpMxI75OoR5/mer0FcLN5AyObBajn KaEA2Yr44m+7VCBrEzY+YYqVUbV6sMe0WsF2Xm0= X-Received: by 2002:a17:906:a4d:b0:7f7:a985:1849 with SMTP id x13-20020a1709060a4d00b007f7a9851849mr3854942ejf.24.1671290709697; Sat, 17 Dec 2022 07:25:09 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id f1-20020a17090631c100b007c07b23a79bsm2089711ejf.213.2022.12.17.07.25.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 17 Dec 2022 07:25:09 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, Richard Henderson , Paolo Bonzini , Peter Xu , Matthew Rosato , Halil Pasic , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , David Hildenbrand , Christian Borntraeger , Thomas Huth , Eric Farman , Ilya Leoshkevich Subject: [PATCH v2 2/5] hw/s390x/pv: Un-inline s390_pv_init() Date: Sat, 17 Dec 2022 16:24:51 +0100 Message-Id: <20221217152454.96388-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221217152454.96388-1-philmd@linaro.org> References: <20221217152454.96388-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62b; envelope-from=philmd@linaro.org; helo=mail-ej1-x62b.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=unavailable 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-bounces+patch=linaro.org@nongnu.org There is no point in having s390_pv_init() inlined. Directly call s390_pv_kvm_init() guarded by kvm_enabled() so the compiler can elide when CONFIG_KVM is not set. Signed-off-by: Philippe Mathieu-Daudé --- hw/s390x/pv.c | 4 +++- hw/s390x/s390-virtio-ccw.c | 6 ++++-- include/hw/s390x/pv.h | 13 ------------- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/hw/s390x/pv.c b/hw/s390x/pv.c index 8dfe92d8df..17c658402d 100644 --- a/hw/s390x/pv.c +++ b/hw/s390x/pv.c @@ -251,7 +251,9 @@ struct S390PVGuestClass { int s390_pv_kvm_init(ConfidentialGuestSupport *cgs, Error **errp) { - if (!object_dynamic_cast(OBJECT(cgs), TYPE_S390_PV_GUEST)) { + assert(kvm_enabled()); + + if (!cgs || !object_dynamic_cast(OBJECT(cgs), TYPE_S390_PV_GUEST)) { return 0; } diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 2e64ffab45..d9a96e315e 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -255,8 +255,10 @@ static void ccw_init(MachineState *machine) /* init CPUs (incl. CPU model) early so s390_has_feature() works */ s390_init_cpus(machine); - /* Need CPU model to be determined before we can set up PV */ - s390_pv_init(machine->cgs, &error_fatal); + if (kvm_enabled()) { + /* Need CPU model to be determined before we can set up PV */ + s390_pv_kvm_init(machine->cgs, &error_fatal); + } s390_flic_init(); diff --git a/include/hw/s390x/pv.h b/include/hw/s390x/pv.h index 9360aa1091..fad61cc6c6 100644 --- a/include/hw/s390x/pv.h +++ b/include/hw/s390x/pv.h @@ -12,7 +12,6 @@ #ifndef HW_S390_PV_H #define HW_S390_PV_H -#include "qapi/error.h" #include "sysemu/kvm.h" #ifdef CONFIG_KVM @@ -78,17 +77,5 @@ static inline int kvm_s390_dump_completion_data(void *buff) { return 0; } #endif /* CONFIG_KVM */ int s390_pv_kvm_init(ConfidentialGuestSupport *cgs, Error **errp); -static inline int s390_pv_init(ConfidentialGuestSupport *cgs, Error **errp) -{ - if (!cgs) { - return 0; - } - if (kvm_enabled()) { - return s390_pv_kvm_init(cgs, errp); - } - - error_setg(errp, "Protected Virtualization requires KVM"); - return -1; -} #endif /* HW_S390_PV_H */