From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 3/7] arm: boot: Add secure_board_setup flag
Date: Tue, 10 Nov 2015 13:51:43 +0000 [thread overview]
Message-ID: <1447163507-26627-4-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1447163507-26627-1-git-send-email-peter.maydell@linaro.org>
From: Peter Crosthwaite <crosthwaitepeter@gmail.com>
Add a flag that when set, will cause the primary CPU to start in secure
mode, even if the overall boot is non-secure. This is useful for when
there is a board-setup blob that needs to run from secure mode, but
device and secondary CPU init should still be done as-normal for a non-
secure boot.
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Message-id: d1170774d5446d715fced7739edfc61a5be931f9.1447007690.git.crosthwaite.peter@gmail.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/arm/boot.c | 10 +++++++++-
include/hw/arm/arm.h | 6 ++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index b0879a5..75f69bf 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -11,6 +11,7 @@
#include "hw/hw.h"
#include "hw/arm/arm.h"
#include "hw/arm/linux-boot-if.h"
+#include "sysemu/kvm.h"
#include "sysemu/sysemu.h"
#include "hw/boards.h"
#include "hw/loader.h"
@@ -495,7 +496,8 @@ static void do_cpu_reset(void *opaque)
}
/* Set to non-secure if not a secure boot */
- if (!info->secure_boot) {
+ if (!info->secure_boot &&
+ (cs != first_cpu || !info->secure_board_setup)) {
/* Linux expects non-secure state */
env->cp15.scr_el3 |= SCR_NS;
}
@@ -598,6 +600,12 @@ static void arm_load_kernel_notify(Notifier *notifier, void *data)
struct arm_boot_info *info =
container_of(n, struct arm_boot_info, load_kernel_notifier);
+ /* The board code is not supposed to set secure_board_setup unless
+ * running its code in secure mode is actually possible, and KVM
+ * doesn't support secure.
+ */
+ assert(!(info->secure_board_setup && kvm_enabled()));
+
/* Load the kernel. */
if (!info->kernel_filename || info->firmware_loaded) {
diff --git a/include/hw/arm/arm.h b/include/hw/arm/arm.h
index 67ba7db..c26b0e3 100644
--- a/include/hw/arm/arm.h
+++ b/include/hw/arm/arm.h
@@ -97,6 +97,12 @@ struct arm_boot_info {
hwaddr board_setup_addr;
void (*write_board_setup)(ARMCPU *cpu,
const struct arm_boot_info *info);
+
+ /* If set, the board specific loader/setup blob will be run from secure
+ * mode, regardless of secure_boot. The blob becomes responsible for
+ * changing to non-secure state if implementing a non-secure boot
+ */
+ bool secure_board_setup;
};
/**
--
1.9.1
next prev parent reply other threads:[~2015-11-10 13:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-10 13:51 [Qemu-devel] [PULL 0/7] target-arm queue Peter Maydell
2015-11-10 13:51 ` [Qemu-devel] [PULL 1/7] target-arm: Fix gdb singlestep handling in arm_debug_excp_handler() Peter Maydell
2015-11-10 13:51 ` [Qemu-devel] [PULL 2/7] hw/intc/arm_gic: Remove the definition of NUM_CPU Peter Maydell
2015-11-10 13:51 ` Peter Maydell [this message]
2015-11-10 13:51 ` [Qemu-devel] [PULL 4/7] arm: highbank: Defeature CPU override Peter Maydell
2015-11-10 13:51 ` [Qemu-devel] [PULL 5/7] arm: highbank: Implement PSCI and dummy monitor Peter Maydell
2015-11-10 13:51 ` [Qemu-devel] [PULL 6/7] hw/arm/virt: error_report cleanups Peter Maydell
2015-11-10 13:51 ` [Qemu-devel] [PULL 7/7] target-arm: Clean up DISAS_UPDATE usage in AArch32 translation code Peter Maydell
2015-11-10 16:38 ` [Qemu-devel] [PULL 0/7] target-arm queue Peter Maydell
2015-11-10 17:12 ` Peter Crosthwaite
2015-11-10 17:13 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1447163507-26627-4-git-send-email-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).