From patchwork Mon Apr 27 06:16:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 464798 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 264AF140318 for ; Mon, 27 Apr 2015 16:16:27 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="verification failed; unprotected key" header.d=gmail.com header.i=@gmail.com header.b=NNJpAiU9; dkim-adsp=none (unprotected policy); dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9236E4BB10; Mon, 27 Apr 2015 08:16:23 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DVSqrapCtD81; Mon, 27 Apr 2015 08:16:23 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AE1474BAF5; Mon, 27 Apr 2015 08:16:22 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BBA8C4BAF5 for ; Mon, 27 Apr 2015 08:16:19 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zbLDINxG4Od1 for ; Mon, 27 Apr 2015 08:16:19 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-vn0-f52.google.com (mail-vn0-f52.google.com [209.85.216.52]) by theia.denx.de (Postfix) with ESMTPS id 3DA1C4BAF2 for ; Mon, 27 Apr 2015 08:16:16 +0200 (CEST) Received: by vnbf1 with SMTP id f1so10729840vnb.5 for ; Sun, 26 Apr 2015 23:16:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:from:to:subject:date:mime-version:content-type; bh=2RC9FU34aERv9yoE/NAczLTf+AlCBUf1zKRBV5enDlI=; b=NNJpAiU9GHD3HtvKccDq46zrp/HFdUxEwYBefMcKmS/8iXydv6MW6rRUONqrhbHyi3 Fu5ABPGHBDHsQexI3X4LwWvQ1PZhlzOdyPHkRcZ+LaK6XE8lAaGo07lGWAW8RrwxbWer d2n/jxGKsaCN8fK7zT9yRtDbMF5OwVUZcO1BUzIYjJLlznT1ual37M0M+LKv1vfg0MQB RK86ZdUuS5k/rL2hK0MlG2zLSSZ4kFWqzhWW2UZ4DjHLXo0p9BcHkQf8q3UsxCl1BXv7 /ngxmC7MqWfFVIFf5UOlbVBKchurJHESqtqBUYM7QNdDypRJlZvek/obbstiNKOsKrah DHiQ== X-Received: by 10.52.177.230 with SMTP id ct6mr23938832vdc.39.1430115375057; Sun, 26 Apr 2015 23:16:15 -0700 (PDT) Received: from mail.hotmail.com (blu004-wss1s2.hotmail.com. [134.170.2.217]) by mx.google.com with ESMTPSA id cc10sm23403513vdc.3.2015.04.26.23.16.14 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 26 Apr 2015 23:16:14 -0700 (PDT) Received: from BLU436-SMTP85 ([134.170.2.215]) by BLU004-WSS1S2.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.22751); Sun, 26 Apr 2015 23:16:13 -0700 X-TMN: [s78jLnnrrpJFM+BEHdbQQ5FxoxaJDwB2] Message-ID: From: Bin Meng To: Simon Glass , U-Boot Mailing List Date: Mon, 27 Apr 2015 14:16:01 +0800 X-Mailer: git-send-email 1.8.2.1 X-OriginalArrivalTime: 27 Apr 2015 06:16:12.0130 (UTC) FILETIME=[A8AE3420:01D080B1] MIME-Version: 1.0 Subject: [U-Boot] [PATCH 1/3] x86: Check PIRQ routing table sanity in the F segment X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Previously the PIRQ routing table sanity check was performed against the original table provided by the platform codes. Now we switch to check its sanity on the final table in the F segment as this one is the one seen by the OS. Signed-off-by: Bin Meng Acked-by: Simon Glass --- arch/x86/lib/pirq_routing.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/arch/x86/lib/pirq_routing.c b/arch/x86/lib/pirq_routing.c index 5a2591a..7a34dcf 100644 --- a/arch/x86/lib/pirq_routing.c +++ b/arch/x86/lib/pirq_routing.c @@ -110,11 +110,7 @@ void pirq_route_irqs(struct irq_info *irq, int num) u32 copy_pirq_routing_table(u32 addr, struct irq_routing_table *rt) { - if (rt->signature != PIRQ_SIGNATURE || rt->version != PIRQ_VERSION || - rt->size % 16) { - debug("Interrupt Routing Table not valid\n"); - return addr; - } + struct irq_routing_table *rom_rt; /* Fix up the table checksum */ rt->checksum = table_compute_checksum(rt, rt->size); @@ -125,5 +121,17 @@ u32 copy_pirq_routing_table(u32 addr, struct irq_routing_table *rt) debug("Copying Interrupt Routing Table to 0x%x\n", addr); memcpy((void *)addr, rt, rt->size); + /* + * We do the sanity check here against the copied table after memcpy, + * as something might go wrong after the memcpy, which is normally + * due to the F segment decode is not turned on to systeam RAM. + */ + rom_rt = (struct irq_routing_table *)addr; + if (rom_rt->signature != PIRQ_SIGNATURE || + rom_rt->version != PIRQ_VERSION || rom_rt->size % 16) { + printf("Interrupt Routing Table not valid\n"); + return addr; + } + return addr + rt->size; }