From patchwork Wed Aug 14 12:23:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wieczorkiewicz, Pawel" X-Patchwork-Id: 11093853 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B6EB713AC for ; Wed, 14 Aug 2019 12:25:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FC7F28429 for ; Wed, 14 Aug 2019 12:25:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F9F527EED; Wed, 14 Aug 2019 12:25:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B939827EED for ; Wed, 14 Aug 2019 12:25:55 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hxsJv-0000kl-KI; Wed, 14 Aug 2019 12:24:03 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hxsJu-0000kg-Kb for xen-devel@lists.xen.org; Wed, 14 Aug 2019 12:24:02 +0000 X-Inumbo-ID: 655e408c-be8e-11e9-b3d1-8fafeb276210 Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 655e408c-be8e-11e9-b3d1-8fafeb276210; Wed, 14 Aug 2019 12:24:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1565785441; x=1597321441; h=from:to:cc:subject:date:message-id:mime-version; bh=yrNAXe+dEC2ynEbvBzxwuCNCTg6a1vFfXbhsgkevspw=; b=D/ClcnA0SlctsXxuQBwIuTwpkkV8HSQbUonVdnyedC3EV1tnS0dtbq2A AXyb67gjPbZl64oKDX2ozuSekRO6eIS92qZKjepFbzsOj6eYW1Kzj5kAL 0nNgQwh+W1GMwhDqLlS0VcfzZHAKJWGKOM6jyQ+J40li2uEU69503716q g=; X-IronPort-AV: E=Sophos;i="5.64,385,1559520000"; d="scan'208";a="693782319" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1a-807d4a99.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 14 Aug 2019 12:23:56 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-807d4a99.us-east-1.amazon.com (Postfix) with ESMTPS id B13EFA1F3E; Wed, 14 Aug 2019 12:23:55 +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; Wed, 14 Aug 2019 12:23:45 +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; Wed, 14 Aug 2019 05:23:13 -0700 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; Wed, 14 Aug 2019 12:23:11 +0000 From: Pawel Wieczorkiewicz To: Date: Wed, 14 Aug 2019 12:23:05 +0000 Message-ID: <20190814122305.20176-1-wipawel@amazon.de> X-Mailer: git-send-email 2.16.5 MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH livepatch-hooks-4 1/1] livepatch: always print XENLOG_ERR information 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: mpohlack@amazon.de, ross.lagerwall@citrix.com, wipawel@amazon.de, konrad.wilk@oracle.com Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP A lot of legitimate error messages were hidden behind debug printk only. Most of these messages can be triggered by loading a malformed hotpatch payload and are priceless for understanding issues with such payloads. Thus, always display all relevant XENLOG_ERR messages. Signed-off-by: Pawel Wieczorkiewicz Reviewed-by: Amit Shah Reviewed-by: Martin Mazein Reviewed-by: Bjoern Doebel Reviewed-by: Ross Lagerwall --- xen/arch/x86/livepatch.c | 16 ++++++++-------- xen/common/livepatch.c | 38 +++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/xen/arch/x86/livepatch.c b/xen/arch/x86/livepatch.c index 406eb910cc..436ee40fe1 100644 --- a/xen/arch/x86/livepatch.c +++ b/xen/arch/x86/livepatch.c @@ -126,7 +126,7 @@ int arch_livepatch_verify_elf(const struct livepatch_elf *elf) hdr->e_ident[EI_CLASS] != ELFCLASS64 || hdr->e_ident[EI_DATA] != ELFDATA2LSB ) { - dprintk(XENLOG_ERR, LIVEPATCH "%s: Unsupported ELF Machine type!\n", + printk(XENLOG_ERR LIVEPATCH "%s: Unsupported ELF Machine type!\n", elf->name); return -EOPNOTSUPP; } @@ -152,7 +152,7 @@ int arch_livepatch_perform_rel(struct livepatch_elf *elf, const struct livepatch_elf_sec *base, const struct livepatch_elf_sec *rela) { - dprintk(XENLOG_ERR, LIVEPATCH "%s: SHT_REL relocation unsupported\n", + printk(XENLOG_ERR LIVEPATCH "%s: SHT_REL relocation unsupported\n", elf->name); return -EOPNOTSUPP; } @@ -172,19 +172,19 @@ int arch_livepatch_perform_rela(struct livepatch_elf *elf, if ( symndx == STN_UNDEF ) { - dprintk(XENLOG_ERR, LIVEPATCH "%s: Encountered STN_UNDEF\n", + printk(XENLOG_ERR LIVEPATCH "%s: Encountered STN_UNDEF\n", elf->name); return -EOPNOTSUPP; } else if ( symndx >= elf->nsym ) { - dprintk(XENLOG_ERR, LIVEPATCH "%s: Relative relocation wants symbol@%u which is past end!\n", + printk(XENLOG_ERR LIVEPATCH "%s: Relative relocation wants symbol@%u which is past end!\n", elf->name, symndx); return -EINVAL; } else if ( !elf->sym[symndx].sym ) { - dprintk(XENLOG_ERR, LIVEPATCH "%s: No symbol@%u\n", + printk(XENLOG_ERR LIVEPATCH "%s: No symbol@%u\n", elf->name, symndx); return -EINVAL; } @@ -222,14 +222,14 @@ int arch_livepatch_perform_rela(struct livepatch_elf *elf, *(int32_t *)dest = val; if ( (int64_t)val != *(int32_t *)dest ) { - dprintk(XENLOG_ERR, LIVEPATCH "%s: Overflow in relocation %u in %s for %s!\n", + printk(XENLOG_ERR LIVEPATCH "%s: Overflow in relocation %u in %s for %s!\n", elf->name, i, rela->name, base->name); return -EOVERFLOW; } break; default: - dprintk(XENLOG_ERR, LIVEPATCH "%s: Unhandled relocation %lu\n", + printk(XENLOG_ERR LIVEPATCH "%s: Unhandled relocation %lu\n", elf->name, ELF64_R_TYPE(r->r_info)); return -EOPNOTSUPP; } @@ -238,7 +238,7 @@ int arch_livepatch_perform_rela(struct livepatch_elf *elf, return 0; bad_offset: - dprintk(XENLOG_ERR, LIVEPATCH "%s: Relative relocation offset is past %s section!\n", + printk(XENLOG_ERR LIVEPATCH "%s: Relative relocation offset is past %s section!\n", elf->name, base->name); return -EINVAL; } diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c index c4a107d91c..585ec9819a 100644 --- a/xen/common/livepatch.c +++ b/xen/common/livepatch.c @@ -217,7 +217,7 @@ static int resolve_old_address(struct livepatch_func *f, f->old_addr = (void *)livepatch_symbols_lookup_by_name(f->name); if ( !f->old_addr ) { - dprintk(XENLOG_ERR, LIVEPATCH "%s: Could not resolve old address of %s\n", + printk(XENLOG_ERR LIVEPATCH "%s: Could not resolve old address of %s\n", elf->name, f->name); return -ENOENT; } @@ -336,7 +336,7 @@ static int move_payload(struct payload *payload, struct livepatch_elf *elf) text_buf = vmalloc_xen(size * PAGE_SIZE); if ( !text_buf ) { - dprintk(XENLOG_ERR, LIVEPATCH "%s: Could not allocate memory for payload!\n", + printk(XENLOG_ERR LIVEPATCH "%s: Could not allocate memory for payload!\n", elf->name); rc = -ENOMEM; goto out; @@ -434,7 +434,7 @@ static bool section_ok(const struct livepatch_elf *elf, if ( sec->sec->sh_size % sz ) { - dprintk(XENLOG_ERR, LIVEPATCH "%s: Wrong size %"PRIuElfWord" of %s (must be multiple of %zu)\n", + printk(XENLOG_ERR LIVEPATCH "%s: Wrong size %"PRIuElfWord" of %s (must be multiple of %zu)\n", elf->name, sec->sec->sh_size, sec->name, sz); return false; } @@ -456,7 +456,7 @@ static int check_xen_build_id(const struct payload *payload) return rc; if ( payload->xen_dep.len != len || memcmp(id, payload->xen_dep.p, len) ) { - dprintk(XENLOG_ERR, "%s%s: check against hypervisor build-id failed!\n", + printk(XENLOG_ERR LIVEPATCH "%s%s: check against hypervisor build-id failed!\n", LIVEPATCH, payload->name); return -EINVAL; } @@ -479,21 +479,21 @@ static int check_special_sections(const struct livepatch_elf *elf) sec = livepatch_elf_sec_by_name(elf, names[i]); if ( !sec ) { - dprintk(XENLOG_ERR, LIVEPATCH "%s: %s is missing!\n", + printk(XENLOG_ERR LIVEPATCH "%s: %s is missing!\n", elf->name, names[i]); return -EINVAL; } if ( !sec->sec->sh_size ) { - dprintk(XENLOG_ERR, LIVEPATCH "%s: %s is empty!\n", + printk(XENLOG_ERR LIVEPATCH "%s: %s is empty!\n", elf->name, names[i]); return -EINVAL; } if ( test_and_set_bit(i, found) ) { - dprintk(XENLOG_ERR, LIVEPATCH "%s: %s was seen more than once!\n", + printk(XENLOG_ERR LIVEPATCH "%s: %s was seen more than once!\n", elf->name, names[i]); return -EINVAL; } @@ -529,21 +529,21 @@ static int check_patching_sections(const struct livepatch_elf *elf) sec = livepatch_elf_sec_by_name(elf, names[i]); if ( !sec ) { - dprintk(XENLOG_INFO, LIVEPATCH "%s: %s is missing!\n", + dprintk(XENLOG_DEBUG, LIVEPATCH "%s: %s is missing!\n", elf->name, names[i]); continue; /* This section is optional */ } if ( !sec->sec->sh_size ) { - dprintk(XENLOG_ERR, LIVEPATCH "%s: %s is empty!\n", + printk(XENLOG_ERR LIVEPATCH "%s: %s is empty!\n", elf->name, names[i]); return -EINVAL; } if ( test_and_set_bit(i, found) ) { - dprintk(XENLOG_ERR, LIVEPATCH "%s: %s was seen more than once!\n", + printk(XENLOG_ERR LIVEPATCH "%s: %s was seen more than once!\n", elf->name, names[i]); return -EINVAL; } @@ -615,7 +615,7 @@ static int prepare_payload(struct payload *payload, if ( f->version != LIVEPATCH_PAYLOAD_VERSION ) { - dprintk(XENLOG_ERR, LIVEPATCH "%s: Wrong version (%u). Expected %d!\n", + printk(XENLOG_ERR LIVEPATCH "%s: Wrong version (%u). Expected %d!\n", elf->name, f->version, LIVEPATCH_PAYLOAD_VERSION); return -EOPNOTSUPP; } @@ -623,7 +623,7 @@ static int prepare_payload(struct payload *payload, /* 'old_addr', 'new_addr', 'new_size' can all be zero. */ if ( !f->old_size ) { - dprintk(XENLOG_ERR, LIVEPATCH "%s: Address or size fields are zero!\n", + printk(XENLOG_ERR LIVEPATCH "%s: Address or size fields are zero!\n", elf->name); return -EINVAL; } @@ -762,14 +762,14 @@ static int prepare_payload(struct payload *payload, if ( (instr < region->start && instr >= region->end) || (replacement < region->start && replacement >= region->end) ) { - dprintk(XENLOG_ERR, LIVEPATCH "%s Alt patching outside payload: %p!\n", + printk(XENLOG_ERR LIVEPATCH "%s Alt patching outside payload: %p!\n", elf->name, instr); return -EINVAL; } } apply_alternatives(start, end); #else - dprintk(XENLOG_ERR, LIVEPATCH "%s: We don't support alternative patching!\n", + printk(XENLOG_ERR LIVEPATCH "%s: We don't support alternative patching!\n", elf->name); return -EOPNOTSUPP; #endif @@ -792,7 +792,7 @@ static int prepare_payload(struct payload *payload, region->ex = s; region->ex_end = e; #else - dprintk(XENLOG_ERR, LIVEPATCH "%s: We don't support .ex_table!\n", + printk(XENLOG_ERR LIVEPATCH "%s: We don't support .ex_table!\n", elf->name); return -EOPNOTSUPP; #endif @@ -901,7 +901,7 @@ static int build_symbol_table(struct payload *payload, if ( symbols_lookup_by_name(symtab[i].name) || livepatch_symbols_lookup_by_name(symtab[i].name) ) { - dprintk(XENLOG_ERR, LIVEPATCH "%s: duplicate new symbol: %s\n", + printk(XENLOG_ERR LIVEPATCH "%s: duplicate new symbol: %s\n", elf->name, symtab[i].name); xfree(symtab); xfree(strtab); @@ -1652,7 +1652,7 @@ static int build_id_dep(struct payload *payload, bool_t internal) if ( payload->dep.len != len || memcmp(id, payload->dep.p, len) ) { - dprintk(XENLOG_ERR, "%s%s: check against %s build-id failed!\n", + printk(XENLOG_ERR LIVEPATCH "%s%s: check against %s build-id failed!\n", LIVEPATCH, payload->name, name); return -EINVAL; } @@ -1712,7 +1712,7 @@ static int livepatch_action(struct xen_sysctl_livepatch_action *action) /* We should be the last applied one. */ if ( p != data ) { - dprintk(XENLOG_ERR, "%s%s: can't unload. Top is %s!\n", + printk(XENLOG_ERR LIVEPATCH "%s%s: can't unload. Top is %s!\n", LIVEPATCH, data->name, p->name); rc = -EBUSY; break; @@ -1748,7 +1748,7 @@ static int livepatch_action(struct xen_sysctl_livepatch_action *action) */ if ( data->reverted && !data->safe_to_reapply ) { - dprintk(XENLOG_ERR, "%s%s: can't revert as payload has .data. Please unload!\n", + printk(XENLOG_ERR LIVEPATCH "%s%s: can't revert as payload has .data. Please unload!\n", LIVEPATCH, data->name); data->rc = -EINVAL; break;