From patchwork Mon Jun 12 10:40:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9780733 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 851206038F for ; Mon, 12 Jun 2017 10:44:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 766EC2858B for ; Mon, 12 Jun 2017 10:44:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B445285CA; Mon, 12 Jun 2017 10:44:08 +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 A31082858B for ; Mon, 12 Jun 2017 10:44:07 +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 1dKMm8-0001E4-86; Mon, 12 Jun 2017 10:40:48 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKMm6-0001Dm-UI for xen-devel@lists.xenproject.org; Mon, 12 Jun 2017 10:40:47 +0000 Received: from [85.158.137.68] by server-4.bemta-3.messagelabs.com id E0/58-31580-DAF6E395; Mon, 12 Jun 2017 10:40:45 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrNIsWRWlGSWpSXmKPExsXS6fjDS3dNvl2 kwexWc4vvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPFmtesBdM8KlZe7WZtYPxm2MXIySEkkCfx +0EnI4jNK2An0b/6GROILSFgKHF64U0WEJtFQFVi0t0HrCA2m4C6RNuz7WC2iICOxOPuqUA1X BzMAlOYJLZOmw02SFjAReL/ocVsIAkhgTecEl+7lrGDJDgFPCRmbW4C6uAA2iYo8XeHMEiYGW jx/GU9TBMYeWYhZGYhyYCEmYFWr58nBBGWl2jeOpsZIiwtsfwfB0TYXmLr30uMELa2xLKFr5k hbC+Jhuu7WRYwcqxi1ChOLSpLLdI1NNZLKspMzyjJTczM0TU0MNbLTS0uTkxPzUlMKtZLzs/d xAgMWAYg2MG4bbvnIUZJDiYlUd4tV2wihfiS8lMqMxKLM+KLSnNSiw8xanBwCGxeu/oCoxRLX n5eqpIE78Q8u0ghwaLU9NSKtMwcYEzBlEpw8CiJ8N4OB0rzFhck5hZnpkOkTjEqSonz9oH0CY AkMkrz4NpgcXyJUVZKmJcR6CghnoLUotzMElT5V4ziHIxKwryeuUBTeDLzSuCmvwJazAS0+Dr I/bzFJYkIKakGxkkfH21YGix29n6pgqaC44e9WlmnN62rqv4xWTarRmPp+8clXsKxsTPXmR6a oK/oueiHM+uTt42GjYLOyT/eS3lxxLJKSzFWefdILWSRDrZucvVMEbwS9asrQbyCT+bbL8YSY x9R6wDLhhyr8NsW2qkOz33mJEesXtl7Ju+B28zmDZym1WuVWIozEg21mIuKEwHlyVNI3gIAAA == X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-11.tower-31.messagelabs.com!1497264042!74310462!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 42662 invoked from network); 12 Jun 2017 10:40:44 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-11.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 12 Jun 2017 10:40:44 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Mon, 12 Jun 2017 04:40:42 -0600 Message-Id: <593E8BC70200007800161DEB@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.2 Date: Mon, 12 Jun 2017 04:40:39 -0600 From: "Jan Beulich" To: "Paul Durrant" References: <0e704f5e-5845-dc56-6058-d0451d43d842@citrix.com> <2baad09e48864a06873037240b8e39dd@AMSPEX02CL03.citrite.net> <5938048A02000078001604AE@prv-mh.provo.novell.com> <056e566f141c4715867e2bdbbe418977@AMSPEX02CL03.citrite.net> <593806FC02000078001604D1@prv-mh.provo.novell.com> <593813E602000078001605F7@prv-mh.provo.novell.com> <593838D20200007800160859@prv-mh.provo.novell.com> <59383D4F020000780016089F@prv-mh.provo.novell.com> <94bf1caf8b95436fa7b3aed74a172ce1@AMSPEX02CL03.citrite.net> <59396AE10200007800160D0E@prv-mh.provo.novell.com> <593AB92202000078001615A1@prv-mh.provo.novell.com> <40009cf2-ef28-4c70-410e-029b6ac8ffb8@oracle.com> <593ADDBC020000780016171F@prv-mh.provo.novell.com> <86a3251e9ac44a2bb2df23862e458ee0@AMSPEX02CL03.citrite.net> In-Reply-To: <86a3251e9ac44a2bb2df23862e458ee0@AMSPEX02CL03.citrite.net> Mime-Version: 1.0 Cc: Juergen Gross , Andrew Cooper , "Julien Grall \(julien.grall@arm.com\)" , 'Boris Ostrovsky' , "xen-devel\(xen-devel@lists.xenproject.org\)" Subject: Re: [Xen-devel] debian stretch dom0 + xen 4.9 fails to boot 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP >>> On 12.06.17 at 10:14, wrote: > Looking at the code in arch/x86/boot/edd.c in Linux, it sector aligns the > buffer into which it reads the MBR and the sector size is pulled from the EDD > which means, I believe, that the MBR read on the skull canyon would be 4k > aligned. > > What do you think it best to do for Xen 4.9? Hardcoding a 4k alignment is > clearly easy and would work around this BIOS issue but, as you say, it does > grow the image. Reverting Juergen's patch also works round the issue, but > that is more by luck. Re-working the code is preferable, but I guess it's too > late to introduce such code-churn in 4.9. Reverting Jürgen's code is out of question with all the information you've gathered by now. I think re-working the EDD code slightly is the best option. Would you mind giving the attached patch a try? This still slightly grows the trampoline due to a few more instructions being needed, but should still be far better than embedding a whole 4k buffer (and then later finding a BIOS/disk combination which wants even more). Note that I've left a tiny bit of debugging code in there. Jan TODO: remove //temp-s We place the trampoline no lower than at 256k, so we have ample space to read the MBRs of BIOS disks into an aligned buffer right below the trampoline (not doing so has been found to be a problem on a buggy BIOS coming with a Skull Canyon NUC). To facilitate that move MBR reading past EDD info retrieval. Also add a wrap check to the EDD info retrieval loop, to match that in the MBR reading one. Reported-by: Paul Durrant --- Using 512-byte sector size as default right now - perhaps worth considering to use 4k instead. I'm also not sure whether we shouldn't sanity check the sector size some more. --- unstable.orig/xen/arch/x86/boot/edd.S 2017-02-09 14:28:18.000000000 +0100 +++ unstable/xen/arch/x86/boot/edd.S 2017-06-12 12:33:36.353082705 +0200 @@ -26,46 +26,6 @@ get_edd: cmpb $2, bootsym(opt_edd) # edd=off ? je edd_done - cmpb $1, bootsym(opt_edd) # edd=skipmbr ? - je edd_start - -# Read the first sector of each BIOS disk device and store the 4-byte signature -edd_mbr_sig_start: - movb $0x80, %dl # from device 80 - movw $bootsym(boot_mbr_signature),%bx # store buffer ptr in bx -edd_mbr_sig_read: - pushw %bx - movb $0x02, %ah # 0x02 Read Sectors - movb $1, %al # read 1 sector - movb $0, %dh # at head 0 - movw $1, %cx # cylinder 0, sector 0 - pushw %es - pushw %ds - popw %es - movw $bootsym(boot_edd_info), %bx # disk's data goes into info - pushw %dx # work around buggy BIOSes - stc # work around buggy BIOSes - int $0x13 - sti # work around buggy BIOSes - popw %dx - popw %es - popw %bx - jc edd_mbr_sig_done # on failure, we're done. - cmpb $0, %ah # some BIOSes do not set CF - jne edd_mbr_sig_done # on failure, we're done. - cmpw $0xaa55, bootsym(boot_edd_info)+0x1fe - jne .Ledd_mbr_sig_next - movl bootsym(boot_edd_info)+EDD_MBR_SIG_OFFSET,%eax - movb %dl, (%bx) # store BIOS drive number - movl %eax, 4(%bx) # store signature from MBR - incb bootsym(boot_mbr_signature_nr) # note that we stored something - addw $8, %bx # increment sig buffer ptr -.Ledd_mbr_sig_next: - incb %dl # increment to next device - jz edd_mbr_sig_done - cmpb $EDD_MBR_SIG_MAX,bootsym(boot_mbr_signature_nr) - jb edd_mbr_sig_read -edd_mbr_sig_done: # Do the BIOS Enhanced Disk Drive calls # This consists of two calls: @@ -136,10 +96,72 @@ edd_legacy_done: edd_next: incb %dl # increment to next device + jz edd_done cmpb $EDD_INFO_MAX,bootsym(boot_edd_info_nr) jb edd_check_ext edd_done: + cmpb $1, bootsym(opt_edd) # edd=skipmbr ? + je .Ledd_mbr_sig_skip + +# Read the first sector of each BIOS disk device and store the 4-byte signature +.Ledd_mbr_sig_start: + pushw %es + movb $0x80, %dl # from device 80 + movw $bootsym(boot_mbr_signature), %bx # store buffer ptr in bx +.Ledd_mbr_sig_read: + pushw %bx + movw $bootsym(boot_edd_info), %bx + movzbw bootsym(boot_edd_info_nr), %cx + jcxz .Ledd_mbr_sig_default +.Ledd_mbr_sig_find_info: + cmpb %dl, (%bx) + ja .Ledd_mbr_sig_default + je .Ledd_mbr_sig_get_size + add $EDDEXTSIZE+EDDPARMSIZE, %bx + loop .Ledd_mbr_sig_find_info +.Ledd_mbr_sig_default: + movw $(512 >> 4), %bx + jmp .Ledd_mbr_sig_set_buf +.Ledd_mbr_sig_get_size: + movw EDDEXTSIZE+0x18(%bx), %bx # sector size + shr $4, %bx # convert to paragraphs + jz .Ledd_mbr_sig_default +.Ledd_mbr_sig_set_buf: + movw %ds, %ax + subw %bx, %ax # disk's data goes right ahead + movw %ax, %es # of trampoline + xorw %bx, %bx + movw %bx, %es:0x1fe(%bx) # clear BIOS magic just in case + pushw %dx # work around buggy BIOSes + stc # work around buggy BIOSes + movw $0x0201, %ax # read 1 sector + movb $0, %dh # at head 0 + movw $1, %cx # cylinder 0, sector 0 + int $0x13 + sti # work around buggy BIOSes + popw %dx + movw %es:0x1fe(%bx), %si + movl %es:EDD_MBR_SIG_OFFSET(%bx), %ecx + popw %bx + jc .Ledd_mbr_sig_done # on failure, we're done. + testb %ah, %ah # some BIOSes do not set CF + jnz .Ledd_mbr_sig_done # on failure, we're done. + cmpw $0xaa55, %si + jne .Ledd_mbr_sig_next + movb %dl, (%bx) # store BIOS drive number + movw %es,2(%bx)//temp + movl %ecx, 4(%bx) # store signature from MBR + incb bootsym(boot_mbr_signature_nr) # note that we stored something + addw $8, %bx # increment sig buffer ptr +.Ledd_mbr_sig_next: + incb %dl # increment to next device + jz .Ledd_mbr_sig_done + cmpb $EDD_MBR_SIG_MAX, bootsym(boot_mbr_signature_nr) + jb .Ledd_mbr_sig_read +.Ledd_mbr_sig_done: + popw %es +.Ledd_mbr_sig_skip: ret GLOBAL(boot_edd_info_nr) @@ -149,4 +171,4 @@ GLOBAL(boot_mbr_signature_nr) GLOBAL(boot_mbr_signature) .fill EDD_MBR_SIG_MAX*8,1,0 GLOBAL(boot_edd_info) - .fill 512,1,0 # big enough for a disc sector + .fill EDD_INFO_MAX * (EDDEXTSIZE + EDDPARMSIZE), 1, 0 --- unstable.orig/xen/arch/x86/platform_hypercall.c 2015-07-20 14:49:38.000000000 +0200 +++ unstable/xen/arch/x86/platform_hypercall.c 2017-06-12 12:22:01.658928095 +0200 @@ -376,6 +376,7 @@ ret_t do_platform_op(XEN_GUEST_HANDLE_PA break; sig = bootsym(boot_mbr_signature) + op->u.firmware_info.index; +printk("MBR[%02x] @ %02x%02x (%04lx)\n", sig->device, sig->pad[2], sig->pad[1], trampoline_phys);//temp op->u.firmware_info.u.disk_mbr_signature.device = sig->device; op->u.firmware_info.u.disk_mbr_signature.mbr_signature =