From patchwork Tue Nov 26 12:25:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wieczorkiewicz, Pawel" X-Patchwork-Id: 11262101 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 75A611875 for ; Tue, 26 Nov 2019 12:26:31 +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 525222068E for ; Tue, 26 Nov 2019 12:26:31 +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="s9lwbRlb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 525222068E 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 1iZZuf-0004a6-J6; Tue, 26 Nov 2019 12:25:49 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iZZue-0004ZH-2S for xen-devel@lists.xenproject.org; Tue, 26 Nov 2019 12:25:48 +0000 X-Inumbo-ID: da0951fa-1047-11ea-83b8-bc764e2007e4 Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id da0951fa-1047-11ea-83b8-bc764e2007e4; Tue, 26 Nov 2019 12:25:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1574771138; x=1606307138; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=FaiVGswvoyzVT2k8JNXfrHofMW8iQRHNbkD2nK28OcE=; b=s9lwbRlbl8IcXqJWZptzV74BWeWYxQbLlpsT3+HU9ej41No/G+XoLCoI /gxOGygiVl4htZhrdwW6uqJzQo58NMY+wnDqfhrlP6BJAYQX1PCw1N4/j BkLafwqlCjbtCJKg0QP52jPq1/jReBEsFedjHTTimJIxwsbrNCOh5dgXb 0=; IronPort-SDR: dAZ8QvixlXia8oISNQPS2vmsKH59axqyxqCUO99jX6WaByoDBgSAFmuPF8qDw/4lxWBoDJzsmM BCBR5S7/wmVQ== X-IronPort-AV: E=Sophos;i="5.69,245,1571702400"; d="scan'208";a="4943797" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2b-81e76b79.us-west-2.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 26 Nov 2019 12:25:36 +0000 Received: from EX13MTAUEA001.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan3.pdx.amazon.com [10.170.41.166]) by email-inbound-relay-2b-81e76b79.us-west-2.amazon.com (Postfix) with ESMTPS id 005B1A1793; Tue, 26 Nov 2019 12:25:34 +0000 (UTC) Received: from EX13D03EUC001.ant.amazon.com (10.43.164.245) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 26 Nov 2019 12:25:34 +0000 Received: from EX13MTAUWC001.ant.amazon.com (10.43.162.135) by EX13D03EUC001.ant.amazon.com (10.43.164.245) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 26 Nov 2019 04:25:33 -0800 Received: from dev-dsk-wipawel-1a-0c4e6d58.eu-west-1.amazon.com (10.4.134.33) by mail-relay.amazon.com (10.43.162.232) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Tue, 26 Nov 2019 12:25:31 +0000 From: Pawel Wieczorkiewicz To: Date: Tue, 26 Nov 2019 12:25:09 +0000 Message-ID: <20191126122511.7409-6-wipawel@amazon.de> X-Mailer: git-send-email 2.16.5 In-Reply-To: <20191126122511.7409-1-wipawel@amazon.de> References: <20191126122511.7409-1-wipawel@amazon.de> MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v3 5/7] create-diff-object: Add support for expectations 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" Extend livepatch_patch_func to support a new field: expect. This new field describes the expected data, its length and whether expectation is enabled. The expectation's data is of opaque padding size. By default the expectation field is zero-out and the expectation is disabled unless explicitly specified in the patch. Signed-off-by: Pawel Wieczorkiewicz Reviewed-by: Ross Lagerwall --- Changed since v1: * Do not bump the payload version again. --- common.h | 11 ++++++++++- create-diff-object.c | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/common.h b/common.h index 9f9cb7b..b6489db 100644 --- a/common.h +++ b/common.h @@ -115,6 +115,14 @@ struct kpatch_elf { }; #define PATCH_INSN_SIZE 5 +#define MAX_REPLACEMENT_SIZE 31 +struct livepatch_expectation { + uint8_t enabled : 1; + uint8_t len : 5; + uint8_t pad : 2; + uint8_t data[MAX_REPLACEMENT_SIZE]; +}; +typedef struct livepatch_expectation livepatch_expectation_t; struct livepatch_patch_func { char *name; @@ -123,9 +131,10 @@ struct livepatch_patch_func { uint32_t new_size; uint32_t old_size; uint8_t version; - unsigned char pad[31]; + unsigned char pad[MAX_REPLACEMENT_SIZE]; uint8_t applied; uint8_t _pad[7]; + livepatch_expectation_t expect; }; struct special_section { diff --git a/create-diff-object.c b/create-diff-object.c index e886d4c..abf3cc7 100644 --- a/create-diff-object.c +++ b/create-diff-object.c @@ -2017,6 +2017,7 @@ static void livepatch_create_patches_sections(struct kpatch_elf *kelf, memset(funcs[index].pad, 0, sizeof funcs[index].pad); funcs[index].applied = 0; memset(funcs[index]._pad, 0, sizeof funcs[index]._pad); + memset(&funcs[index].expect, 0, sizeof funcs[index].expect); /* * Add a relocation that will populate