From patchwork Tue Nov 26 10:07:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wieczorkiewicz, Pawel" X-Patchwork-Id: 11261829 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 3FCB16C1 for ; Tue, 26 Nov 2019 10:10:15 +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 1B916208C0 for ; Tue, 26 Nov 2019 10:10:15 +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="KNEXew7g" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1B916208C0 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 1iZXmm-0007wX-Jq; Tue, 26 Nov 2019 10:09:32 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iZXml-0007v8-Jb for xen-devel@lists.xenproject.org; Tue, 26 Nov 2019 10:09:31 +0000 X-Inumbo-ID: cf3ea382-1034-11ea-a55d-bc764e2007e4 Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id cf3ea382-1034-11ea-a55d-bc764e2007e4; Tue, 26 Nov 2019 10:09:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1574762959; x=1606298959; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=xl1e16bV5ekH62kJZLVa7fVjWIEppLG1Ojj/ahjWXSg=; b=KNEXew7g6piowF4KKhuRC34OippAqwIPtMZ+xytlHe0C9+E+Gbt7vhLG bBbpDE0PY69f5J4wk8cIW1AxbwzUiNqH+9AlimALVHzReqNkj1m/cM+lj /xo8s+gUMBziec1qR+BGTBALqZo9OGSeNmyOiT6pawf/jyi0Ubc6Ko+zz c=; IronPort-SDR: 6nzSWZDmn89kawglgfWAKYru9JN2czriQ9g4RdTkCtDtgVMu03M0eaknw3aKwLxcZqt1nRPGX2 8nMufMXTVOVA== X-IronPort-AV: E=Sophos;i="5.69,245,1571702400"; d="scan'208";a="9921103" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-1d-74cf8b49.us-east-1.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 26 Nov 2019 10:08:39 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1d-74cf8b49.us-east-1.amazon.com (Postfix) with ESMTPS id 8AD0DC0850; Tue, 26 Nov 2019 10:08:38 +0000 (UTC) Received: from EX13D03EUA004.ant.amazon.com (10.43.165.93) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 26 Nov 2019 10:08:23 +0000 Received: from EX13MTAUEB001.ant.amazon.com (10.43.60.96) by EX13D03EUA004.ant.amazon.com (10.43.165.93) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 26 Nov 2019 10:08:22 +0000 Received: from dev-dsk-wipawel-1a-0c4e6d58.eu-west-1.amazon.com (10.4.134.33) by mail-relay.amazon.com (10.43.60.129) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Tue, 26 Nov 2019 10:08:21 +0000 From: Pawel Wieczorkiewicz To: Date: Tue, 26 Nov 2019 10:07:52 +0000 Message-ID: <20191126100801.124844-4-wipawel@amazon.de> X-Mailer: git-send-email 2.16.5 In-Reply-To: <20191126100801.124844-1-wipawel@amazon.de> References: <20191126100801.124844-1-wipawel@amazon.de> MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v6 03/12] livepatch: Export payload structure via livepatch_payload.h 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: Pawel Wieczorkiewicz , Ross Lagerwall , mpohlack@amazon.com, Konrad Rzeszutek Wilk Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The payload structure will be used by the new hooks implementation and therefore its definition has to be exported via the livepatch_payload header. The new hooks will make use of the payload structure fields and the hooks' pointers will also be defined in the payload structure, so the structure along with all field definitions needs to be available to the code being patched in. Signed-off-by: Pawel Wieczorkiewicz Reviewed-by: Andra-Irina Paraschiv Reviewed-by: Eslam Elnikety Reviewed-by: Leonard Foerster Reviewed-by: Martin Pohlack Reviewed-by: Ross Lagerwall Signed-off-by: Konrad Rzeszutek Wilk --- xen/common/livepatch.c | 37 ---------------------------------- xen/include/xen/livepatch_payload.h | 40 +++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 37 deletions(-) diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c index 3951dccaf2..c7325fa81b 100644 --- a/xen/common/livepatch.c +++ b/xen/common/livepatch.c @@ -45,43 +45,6 @@ static LIST_HEAD(applied_list); static unsigned int payload_cnt; static unsigned int payload_version = 1; -/* To contain the ELF Note header. */ -struct livepatch_build_id { - const void *p; - unsigned int len; -}; - -struct payload { - uint32_t state; /* One of the LIVEPATCH_STATE_*. */ - int32_t rc; /* 0 or -XEN_EXX. */ - bool reverted; /* Whether it was reverted. */ - bool safe_to_reapply; /* Can apply safely after revert. */ - struct list_head list; /* Linked to 'payload_list'. */ - const void *text_addr; /* Virtual address of .text. */ - size_t text_size; /* .. and its size. */ - const void *rw_addr; /* Virtual address of .data. */ - size_t rw_size; /* .. and its size (if any). */ - const void *ro_addr; /* Virtual address of .rodata. */ - size_t ro_size; /* .. and its size (if any). */ - unsigned int pages; /* Total pages for [text,rw,ro]_addr */ - struct list_head applied_list; /* Linked to 'applied_list'. */ - struct livepatch_func *funcs; /* The array of functions to patch. */ - unsigned int nfuncs; /* Nr of functions to patch. */ - const struct livepatch_symbol *symtab; /* All symbols. */ - const char *strtab; /* Pointer to .strtab. */ - struct virtual_region region; /* symbol, bug.frame patching and - exception table (x86). */ - unsigned int nsyms; /* Nr of entries in .strtab and symbols. */ - struct livepatch_build_id id; /* ELFNOTE_DESC(.note.gnu.build-id) of the payload. */ - struct livepatch_build_id dep; /* ELFNOTE_DESC(.livepatch.depends). */ - struct livepatch_build_id xen_dep; /* ELFNOTE_DESC(.livepatch.xen_depends). */ - livepatch_loadcall_t *const *load_funcs; /* The array of funcs to call after */ - livepatch_unloadcall_t *const *unload_funcs;/* load and unload of the payload. */ - unsigned int n_load_funcs; /* Nr of the funcs to load and execute. */ - unsigned int n_unload_funcs; /* Nr of funcs to call durung unload. */ - char name[XEN_LIVEPATCH_NAME_SIZE]; /* Name of it. */ -}; - /* Defines an outstanding patching action. */ struct livepatch_work { diff --git a/xen/include/xen/livepatch_payload.h b/xen/include/xen/livepatch_payload.h index 4a1a96d054..99613af2db 100644 --- a/xen/include/xen/livepatch_payload.h +++ b/xen/include/xen/livepatch_payload.h @@ -4,6 +4,15 @@ #ifndef __XEN_LIVEPATCH_PAYLOAD_H__ #define __XEN_LIVEPATCH_PAYLOAD_H__ +#include + +/* To contain the ELF Note header. */ +struct livepatch_build_id { + const void *p; + unsigned int len; +}; + +typedef struct payload livepatch_payload_t; /* * The following definitions are to be used in patches. They are taken @@ -12,6 +21,37 @@ typedef void livepatch_loadcall_t(void); typedef void livepatch_unloadcall_t(void); +struct payload { + uint32_t state; /* One of the LIVEPATCH_STATE_*. */ + int32_t rc; /* 0 or -XEN_EXX. */ + bool reverted; /* Whether it was reverted. */ + bool safe_to_reapply; /* Can apply safely after revert. */ + struct list_head list; /* Linked to 'payload_list'. */ + const void *text_addr; /* Virtual address of .text. */ + size_t text_size; /* .. and its size. */ + const void *rw_addr; /* Virtual address of .data. */ + size_t rw_size; /* .. and its size (if any). */ + const void *ro_addr; /* Virtual address of .rodata. */ + size_t ro_size; /* .. and its size (if any). */ + unsigned int pages; /* Total pages for [text,rw,ro]_addr */ + struct list_head applied_list; /* Linked to 'applied_list'. */ + struct livepatch_func *funcs; /* The array of functions to patch. */ + unsigned int nfuncs; /* Nr of functions to patch. */ + const struct livepatch_symbol *symtab; /* All symbols. */ + const char *strtab; /* Pointer to .strtab. */ + struct virtual_region region; /* symbol, bug.frame patching and + exception table (x86). */ + unsigned int nsyms; /* Nr of entries in .strtab and symbols. */ + struct livepatch_build_id id; /* ELFNOTE_DESC(.note.gnu.build-id) of the payload. */ + struct livepatch_build_id dep; /* ELFNOTE_DESC(.livepatch.depends). */ + struct livepatch_build_id xen_dep; /* ELFNOTE_DESC(.livepatch.xen_depends). */ + livepatch_loadcall_t *const *load_funcs; /* The array of funcs to call after */ + livepatch_unloadcall_t *const *unload_funcs;/* load and unload of the payload. */ + unsigned int n_load_funcs; /* Nr of the funcs to load and execute. */ + unsigned int n_unload_funcs; /* Nr of funcs to call durung unload. */ + char name[XEN_LIVEPATCH_NAME_SIZE]; /* Name of it. */ +}; + /* * LIVEPATCH_LOAD_HOOK macro *