From nobody Sun May 19 07:11:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1615898019; cv=none; d=zohomail.com; s=zohoarc; b=CbuiagyddT51FL9MiFFMQvFFEY0c1TV7lqmtcUUkSYS1IH3ZBPg3Tl7qIpLoaT+0u+HDSMZGvZ6BuRcYTNoMk29sKEhUiZ3ZkT4idCywd/+lWMruQKwhpQiDCFuVXgy0Ufl1uCxn+vC/MlVZK2RL2d4syFRuc0SKU8G7MPITtic= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615898019; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VxyDpOQb81QLqwJ6QSceU7qsAALQpfYd2OG2AcEtet0=; b=EJdCIYNwMwXeg7/4QJSW71NBfAG/Ahwzt0ICEt8EghaxjCrO9DcT3sadwXerYUTxxc1/dbh6Bg6lcNMuzJ1/QmVq4nIfGtK37zU011uXnKzSkoiPO1m7Q+xP7+bZe14e2518UDj9XIuQbJidzFULWeryGeS2zVo9fsnQWtJOhPc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1615898019065118.9361980269083; Tue, 16 Mar 2021 05:33:39 -0700 (PDT) Received: from localhost ([::1]:38034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lM8tF-00015z-Ev for importer@patchew.org; Tue, 16 Mar 2021 08:33:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41996) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lM8nI-0004Zc-3E; Tue, 16 Mar 2021 08:27:29 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:7288 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lM8nB-0007TU-1B; Tue, 16 Mar 2021 08:27:27 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 12GC4Akm049786; Tue, 16 Mar 2021 08:27:05 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 37aum024xv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 16 Mar 2021 08:27:05 -0400 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 12GC4JBo050708; Tue, 16 Mar 2021 08:27:04 -0400 Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0b-001b2d01.pphosted.com with ESMTP id 37aum024x0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 16 Mar 2021 08:27:04 -0400 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 12GCCPUG026981; Tue, 16 Mar 2021 12:27:02 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma02fra.de.ibm.com with ESMTP id 378n181fw4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 16 Mar 2021 12:27:02 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 12GCQxjl40304980 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Mar 2021 12:26:59 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 58405A4040; Tue, 16 Mar 2021 12:26:59 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A59CBA405F; Tue, 16 Mar 2021 12:26:58 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 16 Mar 2021 12:26:58 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=pp1; bh=VxyDpOQb81QLqwJ6QSceU7qsAALQpfYd2OG2AcEtet0=; b=Zshrg+qxM0r+TEb6XDoMes2T3QsLAMDsaFjgrZNFshXHkOD8dZ74tqC9VAFoQKiWVjYN w8WZI3zYI9oCtCmPMxLPzwQ1kZHLSK1BqFhznWajvDbl3qsRPuUJkDqQ3fagz2aE/BuP 0DNeZBRSbH5TF7ecToOpxKxFjL6iFbLvnc3HK/gS7TwuooY0etKKrBtS4iRPC6Di6oI/ Pbr/CkbfE/jpQsbDkCiLljtsg1OTtVnufNkP96EFm4k8wcuFDVigl2B2cf3j+pD9ktax lVOM1+m3qQ9zC5SQ+ZCPDV8g0Kj7PJ9M5wSCs+XbdweYmsSikCf8DzsT4Uud1IEFEdNy jg== From: Halil Pasic To: Cornelia Huck , Thomas Huth , Richard Henderson , David Hildenbrand , Christian Borntraeger , Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefan Hajnoczi , David Gibson , Alexey Kardashevskiy , Alistair Francis , Bin Meng , Palmer Dabbelt , Anup Patel , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alejandro Jimenez , Eduardo Habkost , Laurent Vivier , qemu-s390x@nongnu.org, qemu-devel@nongnu.org Subject: [RFC PATCH 1/2] modules: introduce target specific modules Date: Tue, 16 Mar 2021 13:26:47 +0100 Message-Id: <20210316122648.3372459-2-pasic@linux.ibm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210316122648.3372459-1-pasic@linux.ibm.com> References: <20210316122648.3372459-1-pasic@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369, 18.0.761 definitions=2021-03-16_04:2021-03-16, 2021-03-16 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 spamscore=0 lowpriorityscore=0 adultscore=0 clxscore=1015 bulkscore=0 phishscore=0 impostorscore=0 priorityscore=1501 mlxlogscore=999 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103160085 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: pass client-ip=148.163.158.5; envelope-from=pasic@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Halil Pasic , Boris Fiuczynski , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Bruce Rogers Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) After some back-and-forth in [1] Daniel suggested that we could/should make qemu modules per-target by introducing a dedicated modules directory for each target, which can symlink the modules that do work with and do make sense for the given target. That way we can avoid trying to load modules we know won't work and coming up with convoluted ways for making subsequent failures graceful. The topic of per-target modules was discussed before [1] but, the idea with the symlinks originates from [1]. This patch introduces this new scheme of loading modules without actually introducing any changes to what modules are available to what targets. For the exploitation have look at 'hw/s390x: modularize virtio-gpu-ccw'. [1] https://mail.gnu.org/archive/html/qemu-s390x/2021-03/msg00206.html Signed-off-by: Halil Pasic Suggested-by: "Daniel P. Berrang=C3=A9" --- hw/s390x/meson.build | 1 - include/qemu/module.h | 2 ++ meson.build | 43 +++++++++++++++++++++++++++++- roms/SLOF | 2 +- roms/opensbi | 2 +- scripts/call_generated_script.sh | 6 +++++ scripts/modules/target-symlinks.sh | 31 +++++++++++++++++++++ softmmu/runstate.c | 1 + util/module.c | 13 +++++++-- 9 files changed, 95 insertions(+), 6 deletions(-) create mode 100755 scripts/call_generated_script.sh create mode 100755 scripts/modules/target-symlinks.sh diff --git a/hw/s390x/meson.build b/hw/s390x/meson.build index 91495b5631..0cee605f0a 100644 --- a/hw/s390x/meson.build +++ b/hw/s390x/meson.build @@ -34,7 +34,6 @@ virtio_ss.add(files('virtio-ccw.c')) virtio_ss.add(when: 'CONFIG_VIRTIO_BALLOON', if_true: files('virtio-ccw-ba= lloon.c')) virtio_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-ccw-blk.c'= )) virtio_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('virtio-ccw-cry= pto.c')) -virtio_ss.add(when: 'CONFIG_VIRTIO_GPU', if_true: files('virtio-ccw-gpu.c'= )) virtio_ss.add(when: 'CONFIG_VIRTIO_INPUT', if_true: files('virtio-ccw-inpu= t.c')) virtio_ss.add(when: 'CONFIG_VIRTIO_NET', if_true: files('virtio-ccw-net.c'= )) virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('virtio-ccw-rng.c'= )) diff --git a/include/qemu/module.h b/include/qemu/module.h index 944d403cbd..85a59fde81 100644 --- a/include/qemu/module.h +++ b/include/qemu/module.h @@ -73,4 +73,6 @@ bool module_load_one(const char *prefix, const char *lib_= name, bool mayfail); void module_load_qom_one(const char *type); void module_load_qom_all(void); =20 +void set_emulator_modules_dir(char const *dir_name); + #endif diff --git a/meson.build b/meson.build index a7d2dd429d..8926968182 100644 --- a/meson.build +++ b/meson.build @@ -1749,6 +1749,7 @@ user_ss =3D ss.source_set() util_ss =3D ss.source_set() =20 modules =3D {} +modules_restricted =3D {} hw_arch =3D {} target_arch =3D {} target_softmmu_arch =3D {} @@ -2092,14 +2093,54 @@ common_ss.add(hwcore) # Targets # ########### =20 +module_targets =3D [] foreach m : block_mods + softmmu_mods - shared_module(m.name(), + module_targets +=3D shared_module(m.name(), name_prefix: '', link_whole: m, install: true, install_dir: qemu_moddir) endforeach =20 +foreach target : target_dirs + if not target.endswith('-softmmu') + continue + endif + filtered_module_targets =3D [] + foreach m : module_targets + restricted_to =3D modules_restricted.get(m.name(), []) + if restricted_to.length() =3D=3D 0 or restricted_to.contains(target) + filtered_module_targets +=3D m + endif + endforeach + s =3D custom_target('Make symbolic links script for ' + target + ' modul= es' , + input: filtered_module_targets, + output: 'make_mod_symlinks_'+target+'.sh', + install: false, + depends: filtered_module_targets, + build_by_default: true, + build_always_stale: true, + command: [ + meson.current_source_dir() / 'scripts/modules/target-= symlinks.sh', + '@OUTPUT@', + target, + '@INPUT@' + ]) + + # We run the script as a part of the build so things keep working form t= he + # build tree (without requiring an instalation). I couldn't find a nicer= way. + custom_target('Run symbolic links script for ' + target + ' modules' , + depends: s, + output: 'make_mod_symlinks_'+target+'.sh.dummy', + install: false, + build_by_default: true, + build_always_stale: true, + command: [ + s.full_path(), + meson.current_build_dir() + ]) + meson.add_install_script(meson.current_source_dir() / 'scripts/call_gene= rated_script.sh', s.full_path(), qemu_moddir) +endforeach softmmu_ss.add(authz, blockdev, chardev, crypto, io, qmp) common_ss.add(qom, qemuutil) =20 diff --git a/roms/SLOF b/roms/SLOF index 33a7322de1..e18ddad851 160000 --- a/roms/SLOF +++ b/roms/SLOF @@ -1 +1 @@ -Subproject commit 33a7322de13e9dca4b38851a345a58d37e7a441d +Subproject commit e18ddad8516ff2cfe36ec130200318f7251aa78c diff --git a/roms/opensbi b/roms/opensbi index 234ed8e427..a98258d0b5 160000 --- a/roms/opensbi +++ b/roms/opensbi @@ -1 +1 @@ -Subproject commit 234ed8e427f4d92903123199f6590d144e0d9351 +Subproject commit a98258d0b537a295f517bbc8d813007336731fa9 diff --git a/scripts/call_generated_script.sh b/scripts/call_generated_scri= pt.sh new file mode 100755 index 0000000000..1743b39d7c --- /dev/null +++ b/scripts/call_generated_script.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +SCRIPT=3D$1 +shift + +${SCRIPT} "$@" diff --git a/scripts/modules/target-symlinks.sh b/scripts/modules/target-sy= mlinks.sh new file mode 100755 index 0000000000..25a402a27f --- /dev/null +++ b/scripts/modules/target-symlinks.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +TARGET_FILE=3D"$1" +shift +TARGET_DIR=3D"$1" +shift + +cat > "${TARGET_FILE}" <> "${TARGET_FILE}" + shift +done diff --git a/softmmu/runstate.c b/softmmu/runstate.c index ce8977c6a2..6842827ad5 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -758,6 +758,7 @@ void qemu_init_subsystems(void) =20 atexit(qemu_run_exit_notifiers); =20 + set_emulator_modules_dir(g_strconcat(TARGET_NAME, "-softmmu")); module_call_init(MODULE_INIT_QOM); module_call_init(MODULE_INIT_MIGRATION); =20 diff --git a/util/module.c b/util/module.c index c65060c167..26fc893d98 100644 --- a/util/module.c +++ b/util/module.c @@ -64,6 +64,15 @@ static ModuleTypeList *find_type(module_init_type type) return &init_type_list[type]; } =20 +static char const *emulator_modules_dir; + +void set_emulator_modules_dir(char const *dir_name) +{ + assert(dir_name); + assert(!emulator_modules_dir); + emulator_modules_dir =3D dir_name; +} + void register_module_init(void (*fn)(void), module_init_type type) { ModuleEntry *e; @@ -252,8 +261,8 @@ bool module_load_one(const char *prefix, const char *li= b_name, bool mayfail) assert(n_dirs <=3D ARRAY_SIZE(dirs)); =20 for (i =3D 0; i < n_dirs; i++) { - fname =3D g_strdup_printf("%s/%s%s", - dirs[i], module_name, CONFIG_HOST_DSOSUF); + fname =3D g_strdup_printf("%s/%s/%s%s", dirs[i], emulator_modules_= dir, + module_name, CONFIG_HOST_DSOSUF); ret =3D module_load_file(fname, mayfail, export_symbols); g_free(fname); fname =3D NULL; --=20 2.25.1 From nobody Sun May 19 07:11:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1615897784; cv=none; d=zohomail.com; s=zohoarc; b=mnbqihr1JTn1pUAvgFGRxzqXtyzzdkQOpBTsah7C1XMeRbYzgLpiY2T54drKT8DGwBb1IYgdQnzR/1Hd0BKGDcuHmQyw7spOgZBTXt5rB3arNBTuUjIVlT5BNQ8Ed6ZDmjxU7ktKSFumc4htU9QGAF/Ue92/Ql8domiIqc+dxFU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615897784; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AcImj2OmZjDTFJ3JTUMT0/JAfum/Lw+sAOy2CBntRDo=; b=WUgpJgx0RPutsmc3jI1ZwboDqcNiKBw9hfh60wB5qYWWn8BXWv993np+vAQuzQsMlqcWfN7gMV7qurpXDHV1BnIzxARlEHZe4xWxQAnvq2x8e8LxOPPcx8VHcDz37AqTL7oVPqKMo5gezHjIzIVpEa8M/XWCX3C5ZXpKR9Bw2IU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1615897784109284.3269514739012; Tue, 16 Mar 2021 05:29:44 -0700 (PDT) Received: from localhost ([::1]:59522 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lM8pT-0006bX-0t for importer@patchew.org; Tue, 16 Mar 2021 08:29:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lM8nD-0004VH-C4; Tue, 16 Mar 2021 08:27:24 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:7742) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lM8nB-0007TR-0x; Tue, 16 Mar 2021 08:27:23 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 12GC3pIj067834; Tue, 16 Mar 2021 08:27:06 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 37arhwqqu9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 16 Mar 2021 08:27:06 -0400 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 12GC4JJe071214; Tue, 16 Mar 2021 08:27:05 -0400 Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 37arhwqqth-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 16 Mar 2021 08:27:05 -0400 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 12GCQsvY016005; Tue, 16 Mar 2021 12:27:03 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma04ams.nl.ibm.com with ESMTP id 378n18ju1n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 16 Mar 2021 12:27:03 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 12GCR0Uv39518468 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Mar 2021 12:27:00 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 29C43A4040; Tue, 16 Mar 2021 12:27:00 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7042CA4055; Tue, 16 Mar 2021 12:26:59 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 16 Mar 2021 12:26:59 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=AcImj2OmZjDTFJ3JTUMT0/JAfum/Lw+sAOy2CBntRDo=; b=Zp/U43aIbcOhJdLfscFQjxkudF0/a8WHiIt/pLgPcj6dAAlkAA/GPE5u89qfkiOjTvbY er6UGwnqLrKs7pqjpL6qKspXLzkQ0nPdpJnz1QkkKl8t2VnK2Kr57pr4IpaT4lpexHCr 8E21aY0u+JW4c62sIflKarLwy2+jp154D0v1TuzhCNWYXblBeJbDEnxwwqa0gVMtDF9N 04oF9GBnFzuSz0wHiBWvsnkkrlWO8ZX/O+5Mm/XHhblypvtF5z1+rgDmfS+HVWva+Nw9 4F7RyKa8LnQRlkCrQiDmjHwZHJUAmzfBzPrYtow2SaBmCwnbiY8yoYL4w79HJBkChsxD OQ== From: Halil Pasic To: Cornelia Huck , Thomas Huth , Richard Henderson , David Hildenbrand , Christian Borntraeger , Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefan Hajnoczi , David Gibson , Alexey Kardashevskiy , Alistair Francis , Bin Meng , Palmer Dabbelt , Anup Patel , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alejandro Jimenez , Eduardo Habkost , Laurent Vivier , qemu-s390x@nongnu.org, qemu-devel@nongnu.org Subject: [RFC PATCH 2/2] hw/s390x: modularize virtio-gpu-ccw Date: Tue, 16 Mar 2021 13:26:48 +0100 Message-Id: <20210316122648.3372459-3-pasic@linux.ibm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210316122648.3372459-1-pasic@linux.ibm.com> References: <20210316122648.3372459-1-pasic@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369, 18.0.761 definitions=2021-03-16_04:2021-03-16, 2021-03-16 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 suspectscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 malwarescore=0 lowpriorityscore=0 clxscore=1015 phishscore=0 priorityscore=1501 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103160085 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: pass client-ip=148.163.158.5; envelope-from=pasic@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Halil Pasic , Boris Fiuczynski , "Daniel P. Berrange" , Bruce Rogers Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Since the virtio-gpu-ccw device depends on the hw-display-virtio-gpu module, which provides the type virtio-gpu-device, packaging the hw-display-virtio-gpu module as a separate package that may or may not be installed along with the qemu package leads to problems. Namely if the hw-display-virtio-gpu is absent, qemu continues to advertise virtio-gpu-ccw, but it aborts not only when one attempts using virtio-gpu-ccw, but also when libvirtd's capability probing tries to instantiate the type to introspect it. Let us thus introduce a module named hw-s390x-virtio-gpu-ccw that is going to provide the virtio-gpu-ccw device. The hw-s390x prefix was chosen because it is not a portable device. With virtio-gpu-ccw built as a module, the correct way to package a modularized qemu is to require that hw-display-virtio-gpu must be installed whenever the module hw-s390x-virtio-gpu-ccw. The definition S390_ADAPTER_SUPPRESSIBLE was moved to "cpu.h", per suggestion of Thomas Huth. From interface design perspective, IMHO, not a good thing as it belongs to the public interface of css_register_io_adapters(). We did this because CONFIG_KVM requeires NEED_CPU_H and Thomas, and other commenters did not like the consequences of that. Moving the interrupt related declarations to s390_flic.h was suggested by Cornelia Huck. Signed-off-by: Halil Pasic --- hw/s390x/meson.build | 7 +++++++ include/hw/s390x/css.h | 7 ------- include/hw/s390x/s390_flic.h | 3 +++ target/s390x/cpu.h | 9 ++++++--- util/module.c | 1 + 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/hw/s390x/meson.build b/hw/s390x/meson.build index 0cee605f0a..ad2941f7ca 100644 --- a/hw/s390x/meson.build +++ b/hw/s390x/meson.build @@ -47,3 +47,10 @@ virtio_ss.add(when: 'CONFIG_VHOST_USER_FS', if_true: fil= es('vhost-user-fs-ccw.c' s390x_ss.add_all(when: 'CONFIG_VIRTIO_CCW', if_true: virtio_ss) =20 hw_arch +=3D {'s390x': s390x_ss} + +hw_s390x_modules =3D {} +virtio_gpu_ccw_ss =3D ss.source_set() +virtio_gpu_ccw_ss.add(when: 'CONFIG_VIRTIO_GPU', if_true: [files('virtio-c= cw-gpu.c'), pixman]) +hw_s390x_modules +=3D {'virtio-gpu-ccw': virtio_gpu_ccw_ss} +modules +=3D {'hw-s390x': hw_s390x_modules} +modules_restricted +=3D {'hw-s390x-virtio-gpu-ccw': ['s390x-softmmu']} diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h index 7901ab276c..bba7593d2e 100644 --- a/include/hw/s390x/css.h +++ b/include/hw/s390x/css.h @@ -12,7 +12,6 @@ #ifndef CSS_H #define CSS_H =20 -#include "cpu.h" #include "hw/s390x/adapter.h" #include "hw/s390x/s390_flic.h" #include "hw/s390x/ioinst.h" @@ -233,12 +232,6 @@ uint32_t css_get_adapter_id(CssIoAdapterType type, uin= t8_t isc); void css_register_io_adapters(CssIoAdapterType type, bool swap, bool maska= ble, uint8_t flags, Error **errp); =20 -#ifndef CONFIG_KVM -#define S390_ADAPTER_SUPPRESSIBLE 0x01 -#else -#define S390_ADAPTER_SUPPRESSIBLE KVM_S390_ADAPTER_SUPPRESSIBLE -#endif - #ifndef CONFIG_USER_ONLY SubchDev *css_find_subch(uint8_t m, uint8_t cssid, uint8_t ssid, uint16_t schid); diff --git a/include/hw/s390x/s390_flic.h b/include/hw/s390x/s390_flic.h index e91b15d2d6..3907a13d07 100644 --- a/include/hw/s390x/s390_flic.h +++ b/include/hw/s390x/s390_flic.h @@ -134,6 +134,9 @@ void s390_flic_init(void); S390FLICState *s390_get_flic(void); QEMUS390FLICState *s390_get_qemu_flic(S390FLICState *fs); S390FLICStateClass *s390_get_flic_class(S390FLICState *fs); +void s390_crw_mchk(void); +void s390_io_interrupt(uint16_t subchannel_id, uint16_t subchannel_nr, + uint32_t io_int_parm, uint32_t io_int_word); bool ais_needed(void *opaque); =20 #endif /* HW_S390_FLIC_H */ diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 60d434d5ed..b434b905c0 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -40,6 +40,12 @@ =20 #define S390_MAX_CPUS 248 =20 +#ifndef CONFIG_KVM +#define S390_ADAPTER_SUPPRESSIBLE 0x01 +#else +#define S390_ADAPTER_SUPPRESSIBLE KVM_S390_ADAPTER_SUPPRESSIBLE +#endif + typedef struct PSW { uint64_t mask; uint64_t addr; @@ -806,9 +812,6 @@ int cpu_s390x_signal_handler(int host_signum, void *pin= fo, void *puc); =20 =20 /* interrupt.c */ -void s390_crw_mchk(void); -void s390_io_interrupt(uint16_t subchannel_id, uint16_t subchannel_nr, - uint32_t io_int_parm, uint32_t io_int_word); #define RA_IGNORED 0 void s390_program_interrupt(CPUS390XState *env, uint32_t code, uintptr_t r= a); /* service interrupts are floating therefore we must not pass an cpustate = */ diff --git a/util/module.c b/util/module.c index 26fc893d98..5638202357 100644 --- a/util/module.c +++ b/util/module.c @@ -313,6 +313,7 @@ static struct { { "virtio-gpu-pci-base", "hw-", "display-virtio-gpu-pci" }, { "virtio-gpu-pci", "hw-", "display-virtio-gpu-pci" }, { "vhost-user-gpu-pci", "hw-", "display-virtio-gpu-pci" }, + { "virtio-gpu-ccw", "hw-", "s390x-virtio-gpu-ccw" }, { "virtio-vga-base", "hw-", "display-virtio-vga" }, { "virtio-vga", "hw-", "display-virtio-vga" }, { "vhost-user-vga", "hw-", "display-virtio-vga" }, --=20 2.25.1