Add our own qboot firmware
My qboot fix (https://github.com/bonzini/qboot/pull/28) has (contrary to what I assumed based on the tests passing)
not made it into QEMU yet, so the firmware shipped by it is still affected. This fix not being there silently broke our ktests
since the return code processing can in weird conditions wrongly succeed. The fix for this will be another revision, same with
code that actually uses this. This is just the build.
Test Plan: Build test: `bazel build @com_github_bonzini_qboot//:qboot-bin`. Also tested in subsequent code depending on it.
X-Origin-Diff: phab/D569
GitOrigin-RevId: b693220768bc8e39be21fd90eedc7ab79e9c4bcf
diff --git a/third_party/qboot/qboot.bzl b/third_party/qboot/qboot.bzl
new file mode 100644
index 0000000..bd86d98
--- /dev/null
+++ b/third_party/qboot/qboot.bzl
@@ -0,0 +1,70 @@
+# Copyright 2020 The Monogon Project Authors.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+cc_binary(
+ name = "qboot-elf",
+ srcs = [
+ "code16.c",
+ "code32seg.c",
+ "cstart.S",
+ "entry.S",
+ "fw_cfg.c",
+ "hwsetup.c",
+ "linuxboot.c",
+ "main.c",
+ "malloc.c",
+ "mptable.c",
+ "pci.c",
+ "printf.c",
+ "string.c",
+ "smbios.c",
+ "tables.c",
+ "benchmark.h",
+ ] + glob(["include/*.h"]),
+ copts = [
+ "-m32",
+ "-march=i386",
+ "-mregparm=3",
+ "-fno-stack-protector",
+ "-fno-delete-null-pointer-checks",
+ "-ffreestanding",
+ "-mstringop-strategy=rep_byte",
+ "-minline-all-stringops",
+ "-fno-pic",
+ ],
+ includes = [
+ "include",
+ ],
+ additional_linker_inputs = [
+ "flat.lds",
+ ],
+ linkopts = [
+ "-nostdlib",
+ "-m32",
+ "-Wl,--build-id=none",
+ "-Wl,-T$(location flat.lds)",
+ "-no-pie",
+ ],
+)
+
+# TODO(q3k): move to starlark rule for hermeticity, use toolchain objcopy
+genrule(
+ name = "qboot-bin",
+ srcs = [":qboot-elf"],
+ outs = ["bios.bin"],
+ cmd = "objcopy -O binary $< $@",
+ visibility = ["//visibility:public"],
+)