From patchwork Wed Aug 21 08:19:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wieczorkiewicz, Pawel" X-Patchwork-Id: 11105993 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 534E81864 for ; Wed, 21 Aug 2019 08:21:56 +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 250192339E for ; Wed, 21 Aug 2019 08:21:56 +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="k0Z8j+CK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 250192339E 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 1i0Lra-0000Ay-6V; Wed, 21 Aug 2019 08:21:02 +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 1i0LrY-000089-C1 for xen-devel@lists.xen.org; Wed, 21 Aug 2019 08:21:00 +0000 X-Inumbo-ID: 995cd5e0-c3ec-11e9-adc2-12813bfff9fa Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 995cd5e0-c3ec-11e9-adc2-12813bfff9fa; Wed, 21 Aug 2019 08:20:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1566375656; x=1597911656; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=ZUK7mnqnzUvJEAC7JpM+QGwFjzUJUb1yYGxdXUmn7KY=; b=k0Z8j+CKP7aEFB+O3dD998cge71ElQdvyLYohY4v/E23EcaN0eR1qVuN z/wGIG8R2y0HSYkorKt/OtQ16vm8NoRTQUoTpstXhVPY0NjjWa5sk/9ME 6emk2natPDe2WqYyKjYL6YATsh2tTOIF1uuBb0FJrbGE0qwUuVqtZnR/j w=; X-IronPort-AV: E=Sophos;i="5.64,412,1559520000"; d="scan'208";a="410765065" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2a-538b0bfb.us-west-2.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 21 Aug 2019 08:20:55 +0000 Received: from EX13MTAUEA001.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan3.pdx.amazon.com [10.170.41.166]) by email-inbound-relay-2a-538b0bfb.us-west-2.amazon.com (Postfix) with ESMTPS id 7FBCCA244A; Wed, 21 Aug 2019 08:20:54 +0000 (UTC) Received: from EX13D05EUB002.ant.amazon.com (10.43.166.45) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 21 Aug 2019 08:20:21 +0000 Received: from EX13MTAUWB001.ant.amazon.com (10.43.161.207) by EX13D05EUB002.ant.amazon.com (10.43.166.45) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 21 Aug 2019 08:20:20 +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:20:17 +0000 From: Pawel Wieczorkiewicz To: , Date: Wed, 21 Aug 2019 08:19:25 +0000 Message-ID: <20190821081931.90887-9-wipawel@amazon.de> X-Mailer: git-send-email 2.16.5 In-Reply-To: <20190821081931.90887-1-wipawel@amazon.de> References: <20190821081931.90887-1-wipawel@amazon.de> MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH 08/14] 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: wipawel@amazon.com, Wei Liu , Ross Lagerwall , Andrew Cooper , Konrad Rzeszutek Wilk , mpohlack@amazon.com, Pawel Wieczorkiewicz , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" 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;