~ubuntu-branches/ubuntu/vivid/qemu/vivid

« back to all changes in this revision

Viewing changes to debian/patches/ubuntu/arm64/0022-hw-arm-boot-Add-boot-support-for-AArch64-processor.patch

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2014-02-25 22:31:43 UTC
  • mfrom: (1.8.5)
  • Revision ID: package-import@ubuntu.com-20140225223143-odhqxfc60wxrjl15
Tags: 2.0.0~rc1+dfsg-0ubuntu1
* Merge 2.0.0-rc1
* debian/rules: consolidate ppc filter entries.
* Move qemu-system-arch64 into qemu-system-arm
* debian/patches/define-trusty-machine-type.patch: define a trusty machine
  type, currently the same as pc-i440fx-2.0, to put is in a better position
  to enable live migrations from trusty onward.  (LP: #1294823)
* debian/control: build-dep on libfdt >= 1.4.0  (LP: #1295072)
* Merge latest upstream git to commit dc9528f
* Debian/rules:
  - remove -enable-uname-release=2.6.32
  - don't make the aarch64 target Ubuntu-specific.
* Remove patches which are now upstream:
  - fix-smb-security-share.patch
  - slirp-smb-redirect-port-445-too.patch 
  - linux-user-Implement-sendmmsg-syscall.patch (better version is upstream)
  - signal-added-a-wrapper-for-sigprocmask-function.patch
  - ubuntu/signal-sigsegv-protection-on-do_sigprocmask.patch
  - ubuntu/Don-t-block-SIGSEGV-at-more-places.patch
  - ubuntu/ppc-force-cpu-threads-count-to-be-power-of-2.patch
* add link for /usr/share/qemu/bios-256k.bin
* Remove all linaro patches.
* Remove all arm64/ patches.  Many but not all are upstream.
* Remove CVE-2013-4377.patch which is upstream.
* debian/control-in: don't make qemu-system-aarch64 ubuntu-specific

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
From 7717831c207318babaaf511fecb12298766592c7 Mon Sep 17 00:00:00 2001
2
 
From: "Mian M. Hamayun" <m.hamayun@virtualopensystems.com>
3
 
Date: Tue, 17 Dec 2013 19:42:30 +0000
4
 
Subject: [PATCH 22/49] hw/arm/boot: Add boot support for AArch64 processor
5
 
 
6
 
This commit adds support for booting a single AArch64 CPU by setting
7
 
appropriate registers. The bootloader includes placeholders for Board-ID
8
 
that are used to implement uniform indexing across different bootloaders.
9
 
 
10
 
Signed-off-by: Mian M. Hamayun <m.hamayun@virtualopensystems.com>
11
 
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
 
Message-id: 1385645602-18662-7-git-send-email-peter.maydell@linaro.org
13
 
[PMM:
14
 
 * updated to use ARMInsnFixup style bootloader fragments
15
 
 * dropped virt.c additions
16
 
 * use runtime checks for "is this an AArch64 core" rather than ifdefs
17
 
 * drop some unnecessary setting of registers in reset hook
18
 
]
19
 
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
 
Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
21
 
---
22
 
 hw/arm/boot.c | 43 ++++++++++++++++++++++++++++++++++++++-----
23
 
 1 file changed, 38 insertions(+), 5 deletions(-)
24
 
 
25
 
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
26
 
index 0c05a64..90e9534 100644
27
 
--- a/hw/arm/boot.c
28
 
+++ b/hw/arm/boot.c
29
 
@@ -17,8 +17,13 @@
30
 
 #include "sysemu/device_tree.h"
31
 
 #include "qemu/config-file.h"
32
 
 
33
 
+/* Kernel boot protocol is specified in the kernel docs
34
 
+ * Documentation/arm/Booting and Documentation/arm64/booting.txt
35
 
+ * They have different preferred image load offsets from system RAM base.
36
 
+ */
37
 
 #define KERNEL_ARGS_ADDR 0x100
38
 
 #define KERNEL_LOAD_ADDR 0x00010000
39
 
+#define KERNEL64_LOAD_ADDR 0x00080000
40
 
 
41
 
 typedef enum {
42
 
     FIXUP_NONE = 0,   /* do nothing */
43
 
@@ -37,6 +42,20 @@ typedef struct ARMInsnFixup {
44
 
     FixupType fixup;
45
 
 } ARMInsnFixup;
46
 
 
47
 
+static const ARMInsnFixup bootloader_aarch64[] = {
48
 
+    { 0x580000c0 }, /* ldr x0, arg ; Load the lower 32-bits of DTB */
49
 
+    { 0xaa1f03e1 }, /* mov x1, xzr */
50
 
+    { 0xaa1f03e2 }, /* mov x2, xzr */
51
 
+    { 0xaa1f03e3 }, /* mov x3, xzr */
52
 
+    { 0x58000084 }, /* ldr x4, entry ; Load the lower 32-bits of kernel entry */
53
 
+    { 0xd61f0080 }, /* br x4      ; Jump to the kernel entry point */
54
 
+    { 0, FIXUP_ARGPTR }, /* arg: .word @DTB Lower 32-bits */
55
 
+    { 0 }, /* .word @DTB Higher 32-bits */
56
 
+    { 0, FIXUP_ENTRYPOINT }, /* entry: .word @Kernel Entry Lower 32-bits */
57
 
+    { 0 }, /* .word @Kernel Entry Higher 32-bits */
58
 
+    { 0, FIXUP_TERMINATOR }
59
 
+};
60
 
+
61
 
 /* The worlds second smallest bootloader.  Set r0-r2, then jump to kernel.  */
62
 
 static const ARMInsnFixup bootloader[] = {
63
 
     { 0xe3a00000 }, /* mov     r0, #0 */
64
 
@@ -396,7 +415,12 @@ static void do_cpu_reset(void *opaque)
65
 
             env->thumb = info->entry & 1;
66
 
         } else {
67
 
             if (CPU(cpu) == first_cpu) {
68
 
-                env->regs[15] = info->loader_start;
69
 
+                if (env->aarch64) {
70
 
+                    env->pc = info->loader_start;
71
 
+                } else {
72
 
+                    env->regs[15] = info->loader_start;
73
 
+                }
74
 
+
75
 
                 if (!info->dtb_filename) {
76
 
                     if (old_param) {
77
 
                         set_kernel_args_old(info);
78
 
@@ -418,8 +442,9 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
79
 
     int initrd_size;
80
 
     int is_linux = 0;
81
 
     uint64_t elf_entry;
82
 
-    hwaddr entry;
83
 
+    hwaddr entry, kernel_load_offset;
84
 
     int big_endian;
85
 
+    static const ARMInsnFixup *primary_loader;
86
 
 
87
 
     /* Load the kernel.  */
88
 
     if (!info->kernel_filename) {
89
 
@@ -429,6 +454,14 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
90
 
         return;
91
 
     }
92
 
 
93
 
+    if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
94
 
+        primary_loader = bootloader_aarch64;
95
 
+        kernel_load_offset = KERNEL64_LOAD_ADDR;
96
 
+    } else {
97
 
+        primary_loader = bootloader;
98
 
+        kernel_load_offset = KERNEL_LOAD_ADDR;
99
 
+    }
100
 
+
101
 
     info->dtb_filename = qemu_opt_get(qemu_get_machine_opts(), "dtb");
102
 
 
103
 
     if (!info->secondary_cpu_reset_hook) {
104
 
@@ -469,9 +502,9 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
105
 
                                   &is_linux);
106
 
     }
107
 
     if (kernel_size < 0) {
108
 
-        entry = info->loader_start + KERNEL_LOAD_ADDR;
109
 
+        entry = info->loader_start + kernel_load_offset;
110
 
         kernel_size = load_image_targphys(info->kernel_filename, entry,
111
 
-                                          info->ram_size - KERNEL_LOAD_ADDR);
112
 
+                                          info->ram_size - kernel_load_offset);
113
 
         is_linux = 1;
114
 
     }
115
 
     if (kernel_size < 0) {
116
 
@@ -532,7 +565,7 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
117
 
         fixupcontext[FIXUP_ENTRYPOINT] = entry;
118
 
 
119
 
         write_bootloader("bootloader", info->loader_start,
120
 
-                         bootloader, fixupcontext);
121
 
+                         primary_loader, fixupcontext);
122
 
 
123
 
         if (info->nb_cpus > 1) {
124
 
             info->write_secondary_boot(cpu, info);
125
 
1.8.5.2
126