From patchwork Fri Aug 26 09:09:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sylvain Munaut X-Patchwork-Id: 9300979 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5EF3B601C0 for ; Fri, 26 Aug 2016 09:12:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E35C295E4 for ; Fri, 26 Aug 2016 09:12:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4297A295E7; Fri, 26 Aug 2016 09:12:21 +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, 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 AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 574C8295E4 for ; Fri, 26 Aug 2016 09:12:19 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bdD9F-0007DN-CV; Fri, 26 Aug 2016 09:10:01 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bdD9D-0007Bp-8X for xen-devel@lists.xensource.com; Fri, 26 Aug 2016 09:09:59 +0000 Received: from [193.109.254.147] by server-7.bemta-6.messagelabs.com id D9/61-15404-66700C75; Fri, 26 Aug 2016 09:09:58 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrILMWRWlGSWpSXmKPExsUSnvS7UDeN/UC 4wf9eFot7U96zOzB6bO/bxR7AGMWamZeUX5HAmrFn+jL2guk8FSs61zM2MK7k7GLk5BAS2Mco sfRlEojNJmAiceFiNwuILSKgKLFu9Tswm1nASOL4oy5mEFtYwF3i+4JNjCA2i4CqxI3uyewgN q+Ar0Tf22tgNRICchLnj/9knsDIsYCRYRWjRnFqUVlqka6hoV5SUWZ6RkluYmaOrqGBmV5uan FxYnpqTmJSsV5yfu4mRqBXGIBgB+OnZQGHGCU5mJREeQ+s2R8uxJeUn1KZkVicEV9UmpNafIh RhoNDSYLXmO1AuJBgUWp6akVaZg4wPGDSEhw8SiK8mSBp3uKCxNzizHSI1ClGRSlxXi2QhABI IqM0D64NFpKXGGWlhHkZgQ4R4ilILcrNLEGVf8UozsGoJMxrAzKFJzOvBG76K6DFTECLGV7vB 1lckoiQkmpgFHo3ZcIDH6WJK6oXr9X58yLHPmT9D+4ZmwT74wt7pHV5q5ROPw1rqLmQLD9P83 HiNqZA5eY9WzZfO7v207EPO2b53t+vvat8npoy6/t5K+PPVExfP/XH2uustcFH1nQyCJ94uVF fhi2x+Mqu5IX9PHu+WEm4WepeMdjv/GGmgiNv0qdfTEJ3hJVYijMSDbWYi4oTAamaGPNEAgAA X-Env-Sender: s.munaut@whatever-company.com X-Msg-Ref: server-7.tower-27.messagelabs.com!1472202598!51309186!1 X-Originating-IP: [87.98.251.113] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 6338 invoked from network); 26 Aug 2016 09:09:58 -0000 Received: from gibson.whatever-company.com (HELO gibson.whatever-company.com) (87.98.251.113) by server-7.tower-27.messagelabs.com with SMTP; 26 Aug 2016 09:09:58 -0000 Received: from build-jessie.dev.office.whatever-company.com. (unknown [37.19.15.129]) by gibson.whatever-company.com (Postfix) with ESMTP id 30152416; Fri, 26 Aug 2016 09:48:37 +0000 (UTC) From: Sylvain Munaut To: xen-devel@lists.xensource.com Date: Fri, 26 Aug 2016 09:09:42 +0000 Message-Id: <1472202582-32549-1-git-send-email-s.munaut@whatever-company.com> X-Mailer: git-send-email 2.1.4 Cc: Sylvain Munaut Subject: [Xen-devel] [RFC] x86/boot: Don't use BDA value if it's suspiciously small X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP If we have an multiboot value and the value we got from the BDA seems too small, use the safe one Signed-off-by: Sylvain Munaut --- I need this when using linux-as-a-bootloader (i.e. kexec into Xen) because the BDA is just zero at that point (not entirely sure why tbh). This is the simplest patch I could come up with and that shouldn't change anything for system currently booting. But if the multiboot infos are present, I'm not sure why not use that preferentially since the values from the BDA / EBDA could just be random garbage while the multiboot header has at least some minimal validation (checksum + magic). An error message if no sane value ( i.e. > 64k at min ) can be found at all could be printed too. Took me some time to trace this down and some serial output would have been welcome :) Comments welcome wrt to what people think is best and I can re-spin this. xen/arch/x86/boot/head.S | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index 85770e8..d79fcc5 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -108,6 +108,8 @@ __start: shl $10-4,%edx cmp %eax,%edx /* compare with BDA value */ cmovb %edx,%eax /* and use the smaller */ + cmp $0x1000,%eax /* or if the BDA value is too small */ + cmovb %edx,%eax /* (and probably not valid) */ 2: /* Reserve 64kb for the trampoline */ sub $0x1000,%eax