From patchwork Tue Nov 8 12:33:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Graeme Russ X-Patchwork-Id: 124347 X-Patchwork-Delegate: graeme.russ@gmail.com 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 717481007D4 for ; Tue, 8 Nov 2011 23:36:04 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 00B2229935; Tue, 8 Nov 2011 13:35:02 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 azQ-SVDGWcb5; Tue, 8 Nov 2011 13:35:01 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AFCC629976; Tue, 8 Nov 2011 13:34:24 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5655B2989C for ; Tue, 8 Nov 2011 13:34:11 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 x2wFSq5BctLt for ; Tue, 8 Nov 2011 13:34:11 +0100 (CET) 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-yw0-f44.google.com (mail-yw0-f44.google.com [209.85.213.44]) by theia.denx.de (Postfix) with ESMTPS id F18A9298A0 for ; Tue, 8 Nov 2011 13:33:55 +0100 (CET) Received: by mail-yw0-f44.google.com with SMTP id 2so471727ywt.3 for ; Tue, 08 Nov 2011 04:33:55 -0800 (PST) Received: by 10.236.181.162 with SMTP id l22mr6287621yhm.62.1320755635706; Tue, 08 Nov 2011 04:33:55 -0800 (PST) Received: from localhost.localdomain (d122-104-32-210.sbr6.nsw.optusnet.com.au. [122.104.32.210]) by mx.google.com with ESMTPS id u19sm3948194ank.11.2011.11.08.04.33.53 (version=SSLv3 cipher=OTHER); Tue, 08 Nov 2011 04:33:55 -0800 (PST) From: Graeme Russ To: u-boot@lists.denx.de Date: Tue, 8 Nov 2011 23:33:21 +1100 Message-Id: <1320755603-8695-11-git-send-email-graeme.russ@gmail.com> X-Mailer: git-send-email 1.7.5.2.317.g391b14 In-reply-to: <1320459711-20257-6-git-send-email-graeme.russ@gmail.com> Cc: Graeme Russ Subject: [U-Boot] [PATCH v2 10/12] x86: Ensure IDT and GDT remain 16-byte aligned post relocation X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Some CPUs have strict alignment requirements for these tables Signed-off-by: Graeme Russ --- Changes for v1: - None (skipped to set single version for consolidated series) Changes for v2: - Consolidated patch series arch/x86/cpu/interrupts.c | 2 +- arch/x86/lib/board.c | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) -- 1.7.5.2.317.g391b14 diff --git a/arch/x86/cpu/interrupts.c b/arch/x86/cpu/interrupts.c index e007511..e0958eb 100644 --- a/arch/x86/cpu/interrupts.c +++ b/arch/x86/cpu/interrupts.c @@ -174,7 +174,7 @@ struct desc_ptr { unsigned short segment; } __packed; -struct idt_entry idt[256]; +struct idt_entry idt[256] __attribute__((aligned(16))); struct desc_ptr idt_ptr; diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c index b445179..244a021 100644 --- a/arch/x86/lib/board.c +++ b/arch/x86/lib/board.c @@ -161,19 +161,26 @@ gd_t *gd; static int calculate_relocation_address(void) { - void *text_start = &__text_start; - void *bss_end = &__bss_end; - void *dest_addr; + ulong text_start = (ulong)&__text_start; + ulong bss_end = (ulong)&__bss_end; + ulong dest_addr; ulong rel_offset; /* Calculate destination RAM Address and relocation offset */ - dest_addr = (void *)gd->ram_size; + dest_addr = gd->ram_size; dest_addr -= CONFIG_SYS_STACK_SIZE; dest_addr -= (bss_end - text_start); + + /* + * Round destination address down to 16-byte boundary to keep + * IDT and GDT 16-byte aligned + */ + dest_addr &= ~15; + rel_offset = dest_addr - text_start; gd->start_addr_sp = gd->ram_size; - gd->relocaddr = (ulong)dest_addr; + gd->relocaddr = dest_addr; gd->reloc_off = rel_offset; return 0;