From patchwork Wed Nov 5 13:01:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 40187 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A1FC4240A6 for ; Wed, 5 Nov 2014 13:01:56 +0000 (UTC) Received: by mail-wg0-f69.google.com with SMTP id l18sf449514wgh.8 for ; Wed, 05 Nov 2014 05:01:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:subject :precedence:reply-to:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:errors-to:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=KL6BmeBr6YfAEts1J8DA/HkR00VQhW/l1pdgSTElqOY=; b=hbPSLfT2+hXfTGJHBngUN+SWcmXp6h4Tdh79rZAr341prdvCiTFbqV62EnYvWe3Fkc mDj+F7N5tPzjQaHmdLvOGSL2WteVkcYaS/XSMpqponY1moQ8CO9a/OZnpASEPGvINNuz mMu5HQxOg+9BsFq2ToOuSRVyYhCg+kY2AjYNWg2ZTWbBTzLC5+m1qLrdK6OVLGPRjeH9 LtSDbscQhmK096PQH2LIcWRFd9n6aUBlVG3N50xKDNT43K560gygDhpdmL1L0A5JkY8o Rav/6HLmo7erZ4ApKPSlz2PtXshfFqpycs3Dccg+AnUVhiSfT0NtQbk2t8glmGBMVexG elLg== X-Gm-Message-State: ALoCoQmfK+xGjIRePlJ8LZYT42PTexqyCNjmE8PjWt00GZXymctJUwzeO2I3EFXeTB5hpnmXOZWF X-Received: by 10.181.27.135 with SMTP id jg7mr819992wid.5.1415192515659; Wed, 05 Nov 2014 05:01:55 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.225 with SMTP id p1ls1014139laf.70.gmail; Wed, 05 Nov 2014 05:01:55 -0800 (PST) X-Received: by 10.112.201.201 with SMTP id kc9mr69136940lbc.76.1415192515452; Wed, 05 Nov 2014 05:01:55 -0800 (PST) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id jl10si5957108lbc.96.2014.11.05.05.01.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 05 Nov 2014 05:01:55 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by mail-lb0-f171.google.com with SMTP id b6so596074lbj.30 for ; Wed, 05 Nov 2014 05:01:55 -0800 (PST) X-Received: by 10.152.5.38 with SMTP id p6mr66814149lap.44.1415192515144; Wed, 05 Nov 2014 05:01:55 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp277251lbc; Wed, 5 Nov 2014 05:01:53 -0800 (PST) X-Received: by 10.42.255.72 with SMTP id nh8mr4190800icb.1.1415192512552; Wed, 05 Nov 2014 05:01:52 -0800 (PST) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id i103si4765943ioo.102.2014.11.05.05.01.51 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 05 Nov 2014 05:01:52 -0800 (PST) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Xm0DU-0005vv-Ss; Wed, 05 Nov 2014 13:01:40 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Xm0DT-0005vB-8m for edk2-devel@lists.sourceforge.net; Wed, 05 Nov 2014 13:01:39 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=lersek@redhat.com; helo=mx1.redhat.com; Received: from mx1.redhat.com ([209.132.183.28]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1Xm0DQ-0005wv-QM for edk2-devel@lists.sourceforge.net; Wed, 05 Nov 2014 13:01:39 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sA5D1UYh018466 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 5 Nov 2014 08:01:30 -0500 Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-83.ams2.redhat.com [10.36.116.83]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sA5D1R6n014614 for ; Wed, 5 Nov 2014 08:01:28 -0500 From: Laszlo Ersek To: edk2-devel@lists.sourceforge.net Date: Wed, 5 Nov 2014 14:01:23 +0100 Message-Id: <1415192483-20009-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Spam-Score: -2.1 (--) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.6 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-Headers-End: 1Xm0DQ-0005wv-QM Subject: [edk2] [RFC] OvmfPkg: reproducer for gcc-4.8's -Os causing corruption on X64 X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lersek@redhat.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Build: . edksetup.sh make -C "$EDK_TOOLS_PATH" nice build -p OvmfPkg/OvmfPkgX64.dsc -b DEBUG -t GCC48 -a X64 \ -n $(getconf _NPROCESSORS_ONLN) Run: cp Build/OvmfX64/DEBUG_GCC48/FV/OVMF_VARS.fd vars.fd qemu-system-x86_64 \ -nodefaults \ -nodefconfig \ -nographic \ \ -m 1024 \ -enable-kvm \ -M pc \ \ -drive if=pflash,format=raw,file=Build/OvmfX64/DEBUG_GCC48/FV/OVMF_CODE.fd,readonly \ -drive if=pflash,format=raw,file=vars.fd \ \ -chardev stdio,signal=off,mux=on,id=char0 \ -mon chardev=char0,mode=readline,default \ -serial chardev:char0 \ \ -chardev file,id=char1,path=ovmf.debug.log \ -device isa-debugcon,iobase=0x402,chardev=char1 \ \ -drive file=fat:Build/OvmfX64/DEBUG_GCC48/X64,id=drive0,if=none,format=raw \ -device virtio-blk-pci,drive=drive0 Shell> GccBugReproducer-O0 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1A 0x1B 0x1C 0x1D 0x1E 0x00 Shell> GccBugReproducer-Os 0x3F443E4000 0x3E95894E00 0x3EB0001800 0x3FF686C000 0x3F443E4000 0x3E95894E00 0x3EB0001800 0x3FF686C000 Shell> reset -s Disassembly of the -O0 case (with 'objdump -S Build/OvmfX64/DEBUG_GCC48/X64/OvmfPkg/GccBugReproducer/GccBugReproducer-O0/OUTPUT/GccBugReproducer.obj'): > > Build/OvmfX64/DEBUG_GCC48/X64/OvmfPkg/GccBugReproducer/GccBugReproducer-O0/OUTPUT/GccBugReproducer.obj: file format elf64-x86-64 > > > Disassembly of section .text.Print4: > > 0000000000000000 : > IN UINT64 Dummy2, > IN UINT64 Dummy3, > IN BOOLEAN Recursive, > IN VA_LIST Marker > ) > { > 0: 55 push %rbp > 1: 48 89 e5 mov %rsp,%rbp > 4: 48 83 ec 60 sub $0x60,%rsp > 8: 48 89 4d 10 mov %rcx,0x10(%rbp) > c: 48 89 55 18 mov %rdx,0x18(%rbp) > 10: 4c 89 45 20 mov %r8,0x20(%rbp) > 14: 44 89 c8 mov %r9d,%eax > 17: 88 45 28 mov %al,0x28(%rbp) > UINT64 Value1, Value2, Value3, Value4; > > do { > Value1 = VA_ARG (Marker, UINT64); > 1a: 48 83 45 30 08 addq $0x8,0x30(%rbp) > 1f: 48 8b 45 30 mov 0x30(%rbp),%rax > 23: 48 8b 40 f8 mov -0x8(%rax),%rax > 27: 48 89 45 f8 mov %rax,-0x8(%rbp) > Value2 = VA_ARG (Marker, UINT64); > 2b: 48 83 45 30 08 addq $0x8,0x30(%rbp) > 30: 48 8b 45 30 mov 0x30(%rbp),%rax > 34: 48 8b 40 f8 mov -0x8(%rax),%rax > 38: 48 89 45 f0 mov %rax,-0x10(%rbp) > Value3 = VA_ARG (Marker, UINT64); > 3c: 48 83 45 30 08 addq $0x8,0x30(%rbp) > 41: 48 8b 45 30 mov 0x30(%rbp),%rax > 45: 48 8b 40 f8 mov -0x8(%rax),%rax > 49: 48 89 45 e8 mov %rax,-0x18(%rbp) > Value4 = VA_ARG (Marker, UINT64); > 4d: 48 83 45 30 08 addq $0x8,0x30(%rbp) > 52: 48 8b 45 30 mov 0x30(%rbp),%rax > 56: 48 8b 40 f8 mov -0x8(%rax),%rax > 5a: 48 89 45 e0 mov %rax,-0x20(%rbp) > > if (!Recursive) { > 5e: 80 7d 28 00 cmpb $0x0,0x28(%rbp) > 62: 75 36 jne 9a > AsciiPrint ("0x%02Lx 0x%02Lx 0x%02Lx 0x%02Lx\n", > 64: 4c 8b 45 e8 mov -0x18(%rbp),%r8 > 68: 48 8b 4d f0 mov -0x10(%rbp),%rcx > 6c: 48 8b 45 f8 mov -0x8(%rbp),%rax > 70: 48 8b 55 e0 mov -0x20(%rbp),%rdx > 74: 48 89 54 24 20 mov %rdx,0x20(%rsp) > 79: 4d 89 c1 mov %r8,%r9 > 7c: 49 89 c8 mov %rcx,%r8 > 7f: 48 89 c2 mov %rax,%rdx > 82: 48 b9 00 00 00 00 00 movabs $0x0,%rcx > 89: 00 00 00 > 8c: 48 b8 00 00 00 00 00 movabs $0x0,%rax > 93: 00 00 00 > 96: ff d0 callq *%rax > Value1, Value2, Value3, Value4); > return; > 98: eb 53 jmp ed > } > PrintSeveralQuadruplets (Dummy1, Dummy2, Dummy3, FALSE, > 9a: 48 8b 4d 20 mov 0x20(%rbp),%rcx > 9e: 48 8b 45 18 mov 0x18(%rbp),%rax > a2: 48 8b 55 e0 mov -0x20(%rbp),%rdx > a6: 48 89 54 24 38 mov %rdx,0x38(%rsp) > ab: 48 8b 55 e8 mov -0x18(%rbp),%rdx > af: 48 89 54 24 30 mov %rdx,0x30(%rsp) > b4: 48 8b 55 f0 mov -0x10(%rbp),%rdx > b8: 48 89 54 24 28 mov %rdx,0x28(%rsp) > bd: 48 8b 55 f8 mov -0x8(%rbp),%rdx > c1: 48 89 54 24 20 mov %rdx,0x20(%rsp) > c6: 41 b9 00 00 00 00 mov $0x0,%r9d > cc: 49 89 c8 mov %rcx,%r8 > cf: 48 89 c2 mov %rax,%rdx > d2: 48 8b 4d 10 mov 0x10(%rbp),%rcx > d6: 48 b8 00 00 00 00 00 movabs $0x0,%rax > dd: 00 00 00 > e0: ff d0 callq *%rax > Value1, Value2, Value3, Value4); > } while (Value4 != 0); > e2: 48 83 7d e0 00 cmpq $0x0,-0x20(%rbp) > e7: 0f 85 2d ff ff ff jne 1a > } > ed: c9 leaveq > ee: c3 retq > > Disassembly of section .text.PrintSeveralQuadruplets: > > 0000000000000000 : > IN UINT64 Dummy2, > IN UINT64 Dummy3, > IN BOOLEAN Recursive, > ... > ) > { > 0: 55 push %rbp > 1: 48 89 e5 mov %rsp,%rbp > 4: 48 83 ec 40 sub $0x40,%rsp > 8: 48 89 4d 10 mov %rcx,0x10(%rbp) > c: 48 89 55 18 mov %rdx,0x18(%rbp) > 10: 4c 89 45 20 mov %r8,0x20(%rbp) > 14: 44 89 c8 mov %r9d,%eax > 17: 88 45 28 mov %al,0x28(%rbp) > VA_LIST Marker; > > VA_START (Marker, Recursive); > 1a: 48 8d 45 28 lea 0x28(%rbp),%rax > 1e: 48 83 c0 08 add $0x8,%rax > 22: 48 89 45 f8 mov %rax,-0x8(%rbp) > Print4 (Dummy1 + 1, Dummy2 + 2, Dummy3 + 3, Recursive, Marker); > 26: 0f b6 45 28 movzbl 0x28(%rbp),%eax > 2a: 44 0f b6 c0 movzbl %al,%r8d > 2e: 48 8b 45 20 mov 0x20(%rbp),%rax > 32: 4c 8d 50 03 lea 0x3(%rax),%r10 > 36: 48 8b 45 18 mov 0x18(%rbp),%rax > 3a: 48 8d 50 02 lea 0x2(%rax),%rdx > 3e: 48 8b 45 10 mov 0x10(%rbp),%rax > 42: 48 8d 48 01 lea 0x1(%rax),%rcx > 46: 48 8b 45 f8 mov -0x8(%rbp),%rax > 4a: 48 89 44 24 20 mov %rax,0x20(%rsp) > 4f: 45 89 c1 mov %r8d,%r9d > 52: 4d 89 d0 mov %r10,%r8 > 55: 48 b8 00 00 00 00 00 movabs $0x0,%rax > 5c: 00 00 00 > 5f: ff d0 callq *%rax > VA_END (Marker); > 61: 48 c7 45 f8 00 00 00 movq $0x0,-0x8(%rbp) > 68: 00 > } > 69: c9 leaveq > 6a: c3 retq > > Disassembly of section .text.ShellAppMain: > > 0000000000000000 : > EFIAPI > ShellAppMain ( > IN UINTN Argc, > IN CHAR16 **Argv > ) > { > 0: 55 push %rbp > 1: 48 89 e5 mov %rsp,%rbp > 4: 48 81 ec 20 01 00 00 sub $0x120,%rsp > b: 48 89 4d 10 mov %rcx,0x10(%rbp) > f: 48 89 55 18 mov %rdx,0x18(%rbp) > PrintSeveralQuadruplets (0, 0, 0, TRUE, > 13: 48 c7 84 24 18 01 00 movq $0x0,0x118(%rsp) > 1a: 00 00 00 00 00 > 1f: 48 c7 84 24 10 01 00 movq $0x1e,0x110(%rsp) > 26: 00 1e 00 00 00 > 2b: 48 c7 84 24 08 01 00 movq $0x1d,0x108(%rsp) > 32: 00 1d 00 00 00 > 37: 48 c7 84 24 00 01 00 movq $0x1c,0x100(%rsp) > 3e: 00 1c 00 00 00 > 43: 48 c7 84 24 f8 00 00 movq $0x1b,0xf8(%rsp) > 4a: 00 1b 00 00 00 > 4f: 48 c7 84 24 f0 00 00 movq $0x1a,0xf0(%rsp) > 56: 00 1a 00 00 00 > 5b: 48 c7 84 24 e8 00 00 movq $0x19,0xe8(%rsp) > 62: 00 19 00 00 00 > 67: 48 c7 84 24 e0 00 00 movq $0x18,0xe0(%rsp) > 6e: 00 18 00 00 00 > 73: 48 c7 84 24 d8 00 00 movq $0x17,0xd8(%rsp) > 7a: 00 17 00 00 00 > 7f: 48 c7 84 24 d0 00 00 movq $0x16,0xd0(%rsp) > 86: 00 16 00 00 00 > 8b: 48 c7 84 24 c8 00 00 movq $0x15,0xc8(%rsp) > 92: 00 15 00 00 00 > 97: 48 c7 84 24 c0 00 00 movq $0x14,0xc0(%rsp) > 9e: 00 14 00 00 00 > a3: 48 c7 84 24 b8 00 00 movq $0x13,0xb8(%rsp) > aa: 00 13 00 00 00 > af: 48 c7 84 24 b0 00 00 movq $0x12,0xb0(%rsp) > b6: 00 12 00 00 00 > bb: 48 c7 84 24 a8 00 00 movq $0x11,0xa8(%rsp) > c2: 00 11 00 00 00 > c7: 48 c7 84 24 a0 00 00 movq $0x10,0xa0(%rsp) > ce: 00 10 00 00 00 > d3: 48 c7 84 24 98 00 00 movq $0xf,0x98(%rsp) > da: 00 0f 00 00 00 > df: 48 c7 84 24 90 00 00 movq $0xe,0x90(%rsp) > e6: 00 0e 00 00 00 > eb: 48 c7 84 24 88 00 00 movq $0xd,0x88(%rsp) > f2: 00 0d 00 00 00 > f7: 48 c7 84 24 80 00 00 movq $0xc,0x80(%rsp) > fe: 00 0c 00 00 00 > 103: 48 c7 44 24 78 0b 00 movq $0xb,0x78(%rsp) > 10a: 00 00 > 10c: 48 c7 44 24 70 0a 00 movq $0xa,0x70(%rsp) > 113: 00 00 > 115: 48 c7 44 24 68 09 00 movq $0x9,0x68(%rsp) > 11c: 00 00 > 11e: 48 c7 44 24 60 08 00 movq $0x8,0x60(%rsp) > 125: 00 00 > 127: 48 c7 44 24 58 07 00 movq $0x7,0x58(%rsp) > 12e: 00 00 > 130: 48 c7 44 24 50 06 00 movq $0x6,0x50(%rsp) > 137: 00 00 > 139: 48 c7 44 24 48 05 00 movq $0x5,0x48(%rsp) > 140: 00 00 > 142: 48 c7 44 24 40 04 00 movq $0x4,0x40(%rsp) > 149: 00 00 > 14b: 48 c7 44 24 38 03 00 movq $0x3,0x38(%rsp) > 152: 00 00 > 154: 48 c7 44 24 30 02 00 movq $0x2,0x30(%rsp) > 15b: 00 00 > 15d: 48 c7 44 24 28 01 00 movq $0x1,0x28(%rsp) > 164: 00 00 > 166: 48 c7 44 24 20 00 00 movq $0x0,0x20(%rsp) > 16d: 00 00 > 16f: 41 b9 01 00 00 00 mov $0x1,%r9d > 175: 41 b8 00 00 00 00 mov $0x0,%r8d > 17b: ba 00 00 00 00 mov $0x0,%edx > 180: b9 00 00 00 00 mov $0x0,%ecx > 185: 48 b8 00 00 00 00 00 movabs $0x0,%rax > 18c: 00 00 00 > 18f: ff d0 callq *%rax > 16LLU, 17LLU, 18LLU, 19LLU, > 20LLU, 21LLU, 22LLU, 23LLU, > 24LLU, 25LLU, 26LLU, 27LLU, > 28LLU, 29LLU, 30LLU, 0LLU > ); > return 0; > 191: b8 00 00 00 00 mov $0x0,%eax > } > 196: c9 leaveq > 197: c3 retq Disassembly of the -Os case (with 'objdump -S Build/OvmfX64/DEBUG_GCC48/X64/OvmfPkg/GccBugReproducer/GccBugReproducer-Os/OUTPUT/GccBugReproducer.obj'): > > Build/OvmfX64/DEBUG_GCC48/X64/OvmfPkg/GccBugReproducer/GccBugReproducer-Os/OUTPUT/GccBugReproducer.obj: file format elf64-x86-64 > > > Disassembly of section .text.Print4: > > 0000000000000000 : > IN UINT64 Dummy2, > IN UINT64 Dummy3, > IN BOOLEAN Recursive, > IN VA_LIST Marker > ) > { > 0: 41 55 push %r13 > 2: 45 88 cd mov %r9b,%r13b > 5: 41 54 push %r12 > 7: 49 89 d4 mov %rdx,%r12 > a: 55 push %rbp > b: 48 89 cd mov %rcx,%rbp > e: 57 push %rdi > ) > { > VA_LIST Marker; > > VA_START (Marker, Recursive); > Print4 (Dummy1 + 1, Dummy2 + 2, Dummy3 + 3, Recursive, Marker); > f: 49 8d 78 03 lea 0x3(%r8),%rdi > IN UINT64 Dummy2, > IN UINT64 Dummy3, > IN BOOLEAN Recursive, > IN VA_LIST Marker > ) > { > 13: 56 push %rsi > 14: 53 push %rbx > 15: 48 83 ec 48 sub $0x48,%rsp > 19: 48 8b 9c 24 a0 00 00 mov 0xa0(%rsp),%rbx > 20: 00 > UINT64 Value1, Value2, Value3, Value4; > > do { > Value1 = VA_ARG (Marker, UINT64); > 21: 48 8b 13 mov (%rbx),%rdx > Value2 = VA_ARG (Marker, UINT64); > 24: 4c 8b 43 08 mov 0x8(%rbx),%r8 > 28: 48 83 c3 20 add $0x20,%rbx > Value3 = VA_ARG (Marker, UINT64); > 2c: 4c 8b 4b f0 mov -0x10(%rbx),%r9 > Value4 = VA_ARG (Marker, UINT64); > > if (!Recursive) { > 30: 45 84 ed test %r13b,%r13b > > do { > Value1 = VA_ARG (Marker, UINT64); > Value2 = VA_ARG (Marker, UINT64); > Value3 = VA_ARG (Marker, UINT64); > Value4 = VA_ARG (Marker, UINT64); > 33: 48 8b 73 f8 mov -0x8(%rbx),%rsi > > if (!Recursive) { > 37: 75 1d jne 56 > AsciiPrint ("0x%02Lx 0x%02Lx 0x%02Lx 0x%02Lx\n", > 39: 48 89 74 24 20 mov %rsi,0x20(%rsp) > 3e: 48 b9 00 00 00 00 00 movabs $0x0,%rcx > 45: 00 00 00 > 48: 48 b8 00 00 00 00 00 movabs $0x0,%rax > 4f: 00 00 00 > 52: ff d0 callq *%rax > Value1, Value2, Value3, Value4); > return; > 54: eb 2f jmp 85 > ... > ) > { > VA_LIST Marker; > > VA_START (Marker, Recursive); > 56: 48 8d 44 24 47 lea 0x47(%rsp),%rax > Print4 (Dummy1 + 1, Dummy2 + 2, Dummy3 + 3, Recursive, Marker); > 5b: 45 31 c9 xor %r9d,%r9d > 5e: c6 44 24 3f 00 movb $0x0,0x3f(%rsp) > 63: 49 8d 54 24 02 lea 0x2(%r12),%rdx > 68: 48 8d 4d 01 lea 0x1(%rbp),%rcx > 6c: 49 89 f8 mov %rdi,%r8 > 6f: 48 89 44 24 20 mov %rax,0x20(%rsp) > 74: 48 b8 00 00 00 00 00 movabs $0x0,%rax > 7b: 00 00 00 > 7e: ff d0 callq *%rax > Value1, Value2, Value3, Value4); > return; > } > PrintSeveralQuadruplets (Dummy1, Dummy2, Dummy3, FALSE, > Value1, Value2, Value3, Value4); > } while (Value4 != 0); > 80: 48 85 f6 test %rsi,%rsi > 83: 75 9c jne 21 > } > 85: 48 83 c4 48 add $0x48,%rsp > 89: 5b pop %rbx > 8a: 5e pop %rsi > 8b: 5f pop %rdi > 8c: 5d pop %rbp > 8d: 41 5c pop %r12 > 8f: 41 5d pop %r13 > 91: c3 retq > > Disassembly of section .text.PrintSeveralQuadruplets: > > 0000000000000000 : > IN UINT64 Dummy2, > IN UINT64 Dummy3, > IN BOOLEAN Recursive, > ... > ) > { > 0: 48 83 ec 38 sub $0x38,%rsp > VA_LIST Marker; > > VA_START (Marker, Recursive); > Print4 (Dummy1 + 1, Dummy2 + 2, Dummy3 + 3, Recursive, Marker); > 4: 48 83 c2 02 add $0x2,%rdx > 8: 48 ff c1 inc %rcx > ... > ) > { > VA_LIST Marker; > > VA_START (Marker, Recursive); > b: 48 8d 44 24 60 lea 0x60(%rsp),%rax > IN UINT64 Dummy2, > IN UINT64 Dummy3, > IN BOOLEAN Recursive, > ... > ) > { > 10: 44 88 4c 24 58 mov %r9b,0x58(%rsp) > VA_LIST Marker; > > VA_START (Marker, Recursive); > Print4 (Dummy1 + 1, Dummy2 + 2, Dummy3 + 3, Recursive, Marker); > 15: 49 83 c0 03 add $0x3,%r8 > 19: 45 0f b6 c9 movzbl %r9b,%r9d > 1d: 48 89 44 24 20 mov %rax,0x20(%rsp) > 22: 48 b8 00 00 00 00 00 movabs $0x0,%rax > 29: 00 00 00 > 2c: ff d0 callq *%rax > VA_END (Marker); > } > 2e: 48 83 c4 38 add $0x38,%rsp > 32: c3 retq > > Disassembly of section .text.ShellAppMain: > > 0000000000000000 : > EFIAPI > ShellAppMain ( > IN UINTN Argc, > IN CHAR16 **Argv > ) > { > 0: 48 83 ec 48 sub $0x48,%rsp > ) > { > VA_LIST Marker; > > VA_START (Marker, Recursive); > Print4 (Dummy1 + 1, Dummy2 + 2, Dummy3 + 3, Recursive, Marker); > 4: 41 b9 01 00 00 00 mov $0x1,%r9d > a: 41 b8 03 00 00 00 mov $0x3,%r8d > ... > ) > { > VA_LIST Marker; > > VA_START (Marker, Recursive); > 10: 48 8d 44 24 47 lea 0x47(%rsp),%rax > 15: c6 44 24 3f 01 movb $0x1,0x3f(%rsp) > Print4 (Dummy1 + 1, Dummy2 + 2, Dummy3 + 3, Recursive, Marker); > 1a: ba 02 00 00 00 mov $0x2,%edx > 1f: b9 01 00 00 00 mov $0x1,%ecx > 24: 48 89 44 24 20 mov %rax,0x20(%rsp) > 29: 48 b8 00 00 00 00 00 movabs $0x0,%rax > 30: 00 00 00 > 33: ff d0 callq *%rax > 20LLU, 21LLU, 22LLU, 23LLU, > 24LLU, 25LLU, 26LLU, 27LLU, > 28LLU, 29LLU, 30LLU, 0LLU > ); > return 0; > } > 35: 31 c0 xor %eax,%eax > 37: 48 83 c4 48 add $0x48,%rsp > 3b: c3 retq Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek --- OvmfPkg/GccBugReproducer/GccBugReproducer-O0.inf | 43 +++++++++++ OvmfPkg/GccBugReproducer/GccBugReproducer-Os.inf | 43 +++++++++++ OvmfPkg/GccBugReproducer/GccBugReproducer.c | 93 ++++++++++++++++++++++++ OvmfPkg/OvmfPkgX64.dsc | 8 ++ 4 files changed, 187 insertions(+) create mode 100644 OvmfPkg/GccBugReproducer/GccBugReproducer-O0.inf create mode 100644 OvmfPkg/GccBugReproducer/GccBugReproducer-Os.inf create mode 100644 OvmfPkg/GccBugReproducer/GccBugReproducer.c diff --git a/OvmfPkg/GccBugReproducer/GccBugReproducer-O0.inf b/OvmfPkg/GccBugReproducer/GccBugReproducer-O0.inf new file mode 100644 index 0000000..dd97352 --- /dev/null +++ b/OvmfPkg/GccBugReproducer/GccBugReproducer-O0.inf @@ -0,0 +1,43 @@ +## @file +# An application reproducing local variable corruption in recursive calls with +# gcc-4.8 on the X64 target. +# +# Copyright (C) 2014, Red Hat, Inc. +# Copyright (c) 2010, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials are licensed and made available +# under the terms and conditions of the BSD License which accompanies this +# distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR +# IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010006 + BASE_NAME = GccBugReproducer-O0 + FILE_GUID = 8b779522-e8c8-44c9-a8fb-6472d5323808 + MODULE_TYPE = UEFI_APPLICATION + VERSION_STRING = 0.1 + ENTRY_POINT = ShellCEntryLib + +# +# VALID_ARCHITECTURES = X64 +# + +[Sources] + GccBugReproducer.c + +[Packages] + MdePkg/MdePkg.dec + ShellPkg/ShellPkg.dec + +[LibraryClasses] + UefiLib + ShellCEntryLib + +[BuildOptions] + GCC:DEBUG_GCC48_X64_CC_FLAGS = -O0 diff --git a/OvmfPkg/GccBugReproducer/GccBugReproducer-Os.inf b/OvmfPkg/GccBugReproducer/GccBugReproducer-Os.inf new file mode 100644 index 0000000..2d23c16 --- /dev/null +++ b/OvmfPkg/GccBugReproducer/GccBugReproducer-Os.inf @@ -0,0 +1,43 @@ +## @file +# An application reproducing local variable corruption in recursive calls with +# gcc-4.8 on the X64 target. +# +# Copyright (C) 2014, Red Hat, Inc. +# Copyright (c) 2010, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials are licensed and made available +# under the terms and conditions of the BSD License which accompanies this +# distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR +# IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010006 + BASE_NAME = GccBugReproducer-Os + FILE_GUID = 76bda6c5-c09b-498c-a1c5-699ab23e5c03 + MODULE_TYPE = UEFI_APPLICATION + VERSION_STRING = 0.1 + ENTRY_POINT = ShellCEntryLib + +# +# VALID_ARCHITECTURES = X64 +# + +[Sources] + GccBugReproducer.c + +[Packages] + MdePkg/MdePkg.dec + ShellPkg/ShellPkg.dec + +[LibraryClasses] + UefiLib + ShellCEntryLib + +[BuildOptions] + GCC:DEBUG_GCC48_X64_CC_FLAGS = -Os diff --git a/OvmfPkg/GccBugReproducer/GccBugReproducer.c b/OvmfPkg/GccBugReproducer/GccBugReproducer.c new file mode 100644 index 0000000..c3ebb20 --- /dev/null +++ b/OvmfPkg/GccBugReproducer/GccBugReproducer.c @@ -0,0 +1,93 @@ +/** @file + An application reproducing local variable corruption in recursive calls with + gcc-4.8 on the X64 target. + + Copyright (C) 2014, Red Hat, Inc. + Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.
+ + This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License which accompanies this + distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT + WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +**/ +#include +#include +#include + +VOID +EFIAPI +PrintSeveralQuadruplets ( + IN UINT64 Dummy1, + IN UINT64 Dummy2, + IN UINT64 Dummy3, + IN BOOLEAN Recursive, + ... + ); + +VOID +EFIAPI +Print4 ( + IN UINT64 Dummy1, + IN UINT64 Dummy2, + IN UINT64 Dummy3, + IN BOOLEAN Recursive, + IN VA_LIST Marker + ) +{ + UINT64 Value1, Value2, Value3, Value4; + + do { + Value1 = VA_ARG (Marker, UINT64); + Value2 = VA_ARG (Marker, UINT64); + Value3 = VA_ARG (Marker, UINT64); + Value4 = VA_ARG (Marker, UINT64); + + if (!Recursive) { + AsciiPrint ("0x%02Lx 0x%02Lx 0x%02Lx 0x%02Lx\n", + Value1, Value2, Value3, Value4); + return; + } + PrintSeveralQuadruplets (Dummy1, Dummy2, Dummy3, FALSE, + Value1, Value2, Value3, Value4); + } while (Value4 != 0); +} + +VOID +EFIAPI +PrintSeveralQuadruplets ( + IN UINT64 Dummy1, + IN UINT64 Dummy2, + IN UINT64 Dummy3, + IN BOOLEAN Recursive, + ... + ) +{ + VA_LIST Marker; + + VA_START (Marker, Recursive); + Print4 (Dummy1 + 1, Dummy2 + 2, Dummy3 + 3, Recursive, Marker); + VA_END (Marker); +} + +INTN +EFIAPI +ShellAppMain ( + IN UINTN Argc, + IN CHAR16 **Argv + ) +{ + PrintSeveralQuadruplets (0, 0, 0, TRUE, + 0LLU, 1LLU, 2LLU, 3LLU, + 4LLU, 5LLU, 6LLU, 7LLU, + 8LLU, 9LLU, 10LLU, 11LLU, + 12LLU, 13LLU, 14LLU, 15LLU, + 16LLU, 17LLU, 18LLU, 19LLU, + 20LLU, 21LLU, 22LLU, 23LLU, + 24LLU, 25LLU, 26LLU, 27LLU, + 28LLU, 29LLU, 30LLU, 0LLU + ); + return 0; +} diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index df59272..b518746 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -600,3 +600,11 @@ !endif OvmfPkg/PlatformDxe/Platform.inf + OvmfPkg/GccBugReproducer/GccBugReproducer-O0.inf { + + ShellCEntryLib|ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf + } + OvmfPkg/GccBugReproducer/GccBugReproducer-Os.inf { + + ShellCEntryLib|ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf + }