From patchwork Wed Aug 21 08:19:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wieczorkiewicz, Pawel" X-Patchwork-Id: 11105977 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 05A4E1399 for ; Wed, 21 Aug 2019 08:21:25 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D6A8D2339F for ; Wed, 21 Aug 2019 08:21:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.de header.i=@amazon.de header.b="T04F9xXP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D6A8D2339F Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i0Lqa-0007OB-GP; Wed, 21 Aug 2019 08:20:00 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i0LqZ-0007O0-CT for xen-devel@lists.xen.org; Wed, 21 Aug 2019 08:19:59 +0000 X-Inumbo-ID: 768e18a6-c3ec-11e9-8980-bc764e2007e4 Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 768e18a6-c3ec-11e9-8980-bc764e2007e4; Wed, 21 Aug 2019 08:19:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1566375598; x=1597911598; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=aFy8nN7fYy2nOS38STkuIH5zla0bJjqc8HsaoA6L7iA=; b=T04F9xXPTAulWexJDXRO4gzFLjq/yEmTNvsOoHlUyBY1+F3mLFadAdOX 4eicZcRUm4xxfnjOaLz/516LZodrpJr0H3QtPPhAJSxaT+8nq+rmLcwIY ZK+JlBvMjXXRxY98VqGva62vD5xSzAR1CEfknrhCKAz5dWCwmRMvKXfWi Q=; X-IronPort-AV: E=Sophos;i="5.64,412,1559520000"; d="scan'208";a="416596040" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2b-c7131dcf.us-west-2.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 21 Aug 2019 08:19:55 +0000 Received: from EX13MTAUEA001.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan2.pdx.amazon.com [10.170.41.162]) by email-inbound-relay-2b-c7131dcf.us-west-2.amazon.com (Postfix) with ESMTPS id 068E6A1DB8; Wed, 21 Aug 2019 08:19:54 +0000 (UTC) Received: from EX13D05EUC004.ant.amazon.com (10.43.164.38) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 21 Aug 2019 08:19:54 +0000 Received: from EX13MTAUWB001.ant.amazon.com (10.43.161.207) by EX13D05EUC004.ant.amazon.com (10.43.164.38) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 21 Aug 2019 08:19:53 +0000 Received: from dev-dsk-wipawel-1a-0c4e6d58.eu-west-1.amazon.com (10.4.134.33) by mail-relay.amazon.com (10.43.161.249) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Wed, 21 Aug 2019 08:19:49 +0000 From: Pawel Wieczorkiewicz To: , Date: Wed, 21 Aug 2019 08:19:17 +0000 Message-ID: <20190821081931.90887-1-wipawel@amazon.de> X-Mailer: git-send-email 2.16.5 MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH 00/14] livepatch: new features and fixes X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= , wipawel@amazon.com, Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ross Lagerwall , Ian Jackson , mpohlack@amazon.com, Tim Deegan , Pawel Wieczorkiewicz , Julien Grall , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This series introduces new features to the livepatch functionality as briefly discussed during Xen Developer Summit 2019: [a] and [b]. It also provides a few fixes and some small improvements. FEATURES: 1. independent modules (patches: [1], [2], [3]) * livepatch-build-tools repo dependency [A] Livepatch enforces the following buildid-based dependency chain between hotpatch modules: 1) first module depends on given hypervisor buildid 2) every consecutive module depends on previous module's buildid This way proper hotpatch stack order is maintained and enforced. While it is important for production hotpatches it limits agility and blocks usage of testing or debug hotpatches. These kinds of hotpatch modules are typically expected to be loaded at any time irrespective of current state of the modules stack. [A] livepatch-build: Embed hypervisor build id into every hotpatch 2. pre- and post- apply|revert actions hooks (patches: [4], [5]) * livepatch-build-tools repo dependency [B] This is an implementation of 4 new livepatch module vetoing hooks, that can be optionally supplied along with modules. Hooks that currently exists in the livepatch mechanism aren't agile enough and have various limitations: * run only from within a quiescing zone * cannot conditionally prevent applying or reverting * do not have access to the module context To address these limitations the following has been implemented: 1) pre-apply hook 2) post-apply hook 3) pre-revert hook 4) post-revert hook [B] create-diff-object: Handle extra pre-|post- hooks 3. apply|revert actions replacement hooks (patches: [6], [7], [9]) * livepatch-build-tools repo dependency: [C], [D], [E] To increase hotpatching system's agility and provide more flexiable long-term hotpatch solution, allow to overwrite the default apply and revert action functions with hook-like supplied alternatives. The alternative functions are optional and the default functions are used by default. [C] create-diff-object: Do not create empty .livepatch.funcs section [D] create-diff-object: Handle optional apply|revert hooks [E] create-diff-object: Add support for applied/reverted marker 4. inline asm hotpatching expectations (patches: [10]) * livepatch-build-tools repo dependency: [F] Expectations are designed as optional feature, since the main use of them is planned for inline asm hotpatching. The payload structure is modified as each expectation structure is part of the livepatch_func structure and hence extends the payload. The payload version is bumped to 3 with this change to highlight the ABI modification and enforce proper support. The expectation is manually enabled during inline asm module construction. If enabled, expectation ensures that the expected content of memory is to be found at a given patching (old_addr) location. [F] create-diff-object: Add support for expectations 5. runtime hotpatch metadata support (patches: [11], [12], [13]) Having detailed hotpatch metadata helps to properly identify module's origin and version. It also allows to keep track of the history of hotpatch loads in the system (at least within dmesg buffer size limits). Extend the livepatch list operation to fetch also payloads' metadata. This is achieved by extending the sysctl list interface with 2 extra guest handles: * metadata - an array of arbitrary size strings * metadata_len - an array of metadata strings' lengths (uin32_t each) To unify and simplify the interface, handle the modules' name strings of arbitrary size by copying them in adhering chunks to the userland. 6. python bindings for livepatch operations (patches: [14]) Extend the XC python bindings library to support all common livepatch operations and actions: - status (pyxc_livepatch_status): - action (pyxc_livepatch_action): - upload (pyxc_livepatch_upload): - list (pyxc_livepatch_list): FIXES: 1. always print XENLOG_ERR information (patches: [8]) [a] https://wiki.xenproject.org/wiki/Design_Sessions_2019#LivePatch_improvements_and_features [b] https://lists.xenproject.org/archives/html/xen-devel/2019-07/msg00846.html Pawel Wieczorkiewicz (14): [1] livepatch: Always check hypervisor build ID upon hotpatch upload [2] livepatch: Allow to override inter-modules buildid dependency [3] python: Add XC binding for Xen build ID [4] livepatch: Export payload structure via livepatch_payload.h [5] livepatch: Implement pre-|post- apply|revert hooks [6] livepatch: Add support for apply|revert action replacement hooks [7] livepatch: Do not enforce ELF_LIVEPATCH_FUNC section presence [8] livepatch: always print XENLOG_ERR information [9] livepatch: Add per-function applied/reverted state tracking marker [10] livepatch: Add support for inline asm hotpatching expectations [11] livepatch: Add support for modules .modinfo section metadata [12] livepatch: Handle arbitrary size names with the list operation [13] livepatch: Add metadata runtime retrieval mechanism [14] livepatch: Add python bindings for livepatch operations .gitignore | 1 + docs/misc/livepatch.pandoc | 28 +- tools/libxc/include/xenctrl.h | 68 +++- tools/libxc/xc_misc.c | 162 +++++++-- tools/misc/xen-livepatch.c | 258 ++++++++++---- tools/python/xen/lowlevel/xc/xc.c | 300 ++++++++++++++++ xen/arch/x86/livepatch.c | 36 +- xen/common/livepatch.c | 671 ++++++++++++++++++++++++++++++------ xen/include/public/sysctl.h | 63 +++- xen/include/xen/livepatch.h | 17 +- xen/include/xen/livepatch_payload.h | 83 +++++ xen/test/livepatch/Makefile | 31 +- 12 files changed, 1444 insertions(+), 274 deletions(-)