From patchwork Fri Jun 26 16:42:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe de Dinechin X-Patchwork-Id: 1317846 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=PxvNVb08; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49tjdb4984z9sQx for ; Sat, 27 Jun 2020 02:53:55 +1000 (AEST) Received: from localhost ([::1]:42700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jorbt-0008PG-61 for incoming@patchwork.ozlabs.org; Fri, 26 Jun 2020 12:53:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57942) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jorRp-0005gD-Mj for qemu-devel@nongnu.org; Fri, 26 Jun 2020 12:43:29 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:59037 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jorRm-0006vC-Vt for qemu-devel@nongnu.org; Fri, 26 Jun 2020 12:43:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593189805; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JjxT6rM8zGr6Kdd4CzcuTN7PCxNsll0KV4HDcYs8fyw=; b=PxvNVb08Gg3w85c2bTkZhOVXr9tuzasIWVzgMqF0Da+HqOID9SQ9eSE/zvMqzmHiuPUy5Q V2qKgjcFTJfj2XFLOKbYJ1rgfm86KflUwXQZvK+idOLSjPaRHe3VyIwgCbrF1uDu6xTkiw UFNNR8M0cLglAlyW7A1+I6meAI/EyUc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-231-JkzD1UYTMD-DJIm4l4ouMA-1; Fri, 26 Jun 2020 12:43:20 -0400 X-MC-Unique: JkzD1UYTMD-DJIm4l4ouMA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6A7B480058A; Fri, 26 Jun 2020 16:43:19 +0000 (UTC) Received: from turbo.com (ovpn-112-91.ams2.redhat.com [10.36.112.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83F485C1BB; Fri, 26 Jun 2020 16:43:08 +0000 (UTC) From: Christophe de Dinechin To: qemu-devel@nongnu.org Subject: [PATCH 00/10] RFC: Move SPICE to a load module Date: Fri, 26 Jun 2020 18:42:57 +0200 Message-Id: <20200626164307.3327380-1-dinechin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=207.211.31.81; envelope-from=dinechin@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/26 03:23:21 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: Eduardo Habkost , "Michael S. Tsirkin" , qemu-trivial@nongnu.org, Cleber Rosa , Michael Tokarev , Laurent Vivier , "Dr. David Alan Gilbert" , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" There has been a bit of discussion regarding the possibility to move SPICE code to a module in order to reduce the attack surface and memory usage when SPICE is not used. This WIP series proposes one way to do it that is relatively cheap in terms of code changes, relative to other ideas I tested, and seems to be working on simple test cases, unlike a couple of more "sophisiticated" ideas I tried where I ran into rather nasty SPICE initialization order issues. Furthermore, the approach presented here requires relatively few code changes in order to apply to other components as well. It relies on a couple of macros added to the module.h file, MODIFACE and MODIMPLE. MODIFACE declare the interface for a module function. A module function is transformed into a pointer when you build with modules, and that pointer is used instead of the original function. MODIMPL implements a MODIFACE, and patches the pointer at load time to call the function in the shared library. Thanks to some suggestions from Gerd, I also moved QXL to a module, although at the moment it does not load correctly. There are a few known hacks in the present state, including: - Adding various non-UI files into spice-app.so, which required a couple of ../pwd/foo.o references in the makefile. Not very nice, but I did not want to spend too much time fixing the makefiles. - qmp_query_spice had to be dealt with "manually" because its interface is generated. With these changes, the following shared libraries are no longer needed in the main binary: libspice-server.so.1 => /lib64/libspice-server.so.1 (HEX) libopus.so.0 => /lib64/libopus.so.0 (HEX) liblz4.so.1 => /lib64/liblz4.so.1 (HEX) libgstapp-1.0.so.0 => /lib64/libgstapp-1.0.so.0 (HEX) libgstvideo-1.0.so.0 => /lib64/libgstvideo-1.0.so.0 (HEX) libgstbase-1.0.so.0 => /lib64/libgstbase-1.0.so.0 (HEX) libgstreamer-1.0.so.0 => /lib64/libgstreamer-1.0.so.0 (HEX) libssl.so.1.1 => /lib64/libssl.so.1.1 (HEX) liborc-0.4.so.0 => /lib64/liborc-0.4.so.0 (HEX) I will keep pushing updates on branch "modular-spice" on https://github.com/c3d/qemu.git Christophe de Dinechin (10): modules: Provide macros making it easier to identify module exports minikconf: Pass variables for modules spice: Make spice a module configuration spice: Move all the spice-related code in spice-app.so build: Avoid build failure when building drivers as modules trivial: Remove extra trailing whitespace qxl - FIXME: Build as module build: Add SPICE_CFLAGS and SPICE_LIBS to relevant files spice: Put spice functions in a separate load module REMOVE: Instrumentation to show the module functions being replaced Makefile | 1 + Makefile.objs | 2 ++ Makefile.target | 7 +++++++ audio/Makefile.objs | 2 +- chardev/Makefile.objs | 2 +- configure | 6 +++--- hw/Makefile.objs | 1 + hw/display/Makefile.objs | 4 +++- hw/display/qxl.c | 2 +- hw/i386/Makefile.objs | 1 + include/qemu/module.h | 28 ++++++++++++++++++++++++++++ include/ui/qemu-spice.h | 24 +++++++++++++++--------- monitor/Makefile.objs | 3 +++ monitor/hmp-cmds.c | 6 ++++++ scripts/minikconf.py | 4 ++-- softmmu/Makefile.objs | 2 +- softmmu/vl.c | 1 + stubs/Makefile.objs | 2 +- ui/Makefile.objs | 12 ++++++------ ui/spice-core.c | 31 +++++++++++++++++++++---------- ui/spice-display.c | 2 +- util/module.c | 13 +++++++++++-- 22 files changed, 117 insertions(+), 39 deletions(-)