All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Stabellini <sstabellini@kernel.org>
To: xen-devel@lists.xenproject.org
Cc: Stefano Stabellini <stefanos@xilinx.com>,
	sstabellini@kernel.org, Wei Liu <wl@xen.org>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	George Dunlap <george.dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>,
	Julien Grall <julien.grall@arm.com>,
	Jan Beulich <jbeulich@suse.com>,
	Dario Faggioli <dfaggioli@suse.com>
Subject: [PATCH] xen: debug_registers_trap, perf_counters_trap, and "static_partitioning"
Date: Fri, 31 May 2019 16:00:56 -0700	[thread overview]
Message-ID: <20190531230056.14506-1-sstabellini@kernel.org> (raw)

Introduce two global parameters to disable debug registers trapping and
perf counters trapping. They are only safe to use in static partitiong
scenarios where sched=null is used -- vcpu cannot be migrated from one
pcpu to the next.

Introduce a new simple umbrella command line option
"static_partitioning" that enables vwfi=native, sched=null, and also
sets debug_registers_trap and perf_counters_trap to false.

Signed-off-by: Stefano Stabellini <stefanos@xilinx.com>
CC: Julien Grall <julien.grall@arm.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
CC: George Dunlap <George.Dunlap@eu.citrix.com>
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: Tim Deegan <tim@xen.org>
CC: Wei Liu <wl@xen.org>
CC: George Dunlap <george.dunlap@eu.citrix.com>
CC: Dario Faggioli <dfaggioli@suse.com>
---
This is not ideal. The best course of action would be to implement
proper context switching of all the necessary debug and perf counters
registers. This is an imperfect shortcut, which could reasonably be left
out of the upstream tree but I shared it with others for their
convenience.
---
 xen/arch/arm/traps.c    | 26 +++++++++++++++++++++++++-
 xen/common/schedule.c   |  2 +-
 xen/include/xen/sched.h |  1 +
 3 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index 5c18e918b0..d6eaffde23 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -118,6 +118,28 @@ static int __init parse_vwfi(const char *s)
 }
 custom_param("vwfi", parse_vwfi);
 
+static bool debug_registers_trap = true;
+static bool perf_counters_trap = true;
+
+static int __init opt_static_partitioning(const char *s)
+{
+    if ( strcmp(s, "true") && 
+         strcmp(s, "True") &&
+         strcmp(s, "1") )
+        return 0;
+
+    vwfi = NATIVE;
+    debug_registers_trap = false;
+    perf_counters_trap = false;
+    memcpy(opt_sched, "null", 5);
+
+    /* Disable Trap Debug and Performance Monitor now for CPU0 */
+    WRITE_SYSREG(HDCR_TDRA, MDCR_EL2);
+
+    return 0;
+}
+custom_param("static_partitioning", opt_static_partitioning);
+
 register_t get_default_hcr_flags(void)
 {
     return  (HCR_PTW|HCR_BSU_INNER|HCR_AMO|HCR_IMO|HCR_FMO|HCR_VM|
@@ -165,7 +187,9 @@ void init_traps(void)
     WRITE_SYSREG((vaddr_t)hyp_traps_vector, VBAR_EL2);
 
     /* Trap Debug and Performance Monitor accesses */
-    WRITE_SYSREG(HDCR_TDRA|HDCR_TDOSA|HDCR_TDA|HDCR_TPM|HDCR_TPMCR,
+    WRITE_SYSREG(HDCR_TDRA |
+                 (debug_registers_trap ? HDCR_TDOSA|HDCR_TDA : 0) |
+                 (perf_counters_trap ? HDCR_TPM|HDCR_TPMCR : 0),
                  MDCR_EL2);
 
     /* Trap CP15 c15 used for implementation defined registers */
diff --git a/xen/common/schedule.c b/xen/common/schedule.c
index 049f93f7aa..51eb3d770b 100644
--- a/xen/common/schedule.c
+++ b/xen/common/schedule.c
@@ -39,7 +39,7 @@
 #include <xen/err.h>
 
 /* opt_sched: scheduler - default to configured value */
-static char __initdata opt_sched[10] = CONFIG_SCHED_DEFAULT;
+char __initdata opt_sched[10] = CONFIG_SCHED_DEFAULT;
 string_param("sched", opt_sched);
 
 /* if sched_smt_power_savings is set,
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index b73ccbdf3a..c40a1b5dbc 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -906,6 +906,7 @@ static inline bool is_vcpu_online(const struct vcpu *v)
 }
 
 extern bool sched_smt_power_savings;
+extern char opt_sched[10];
 
 extern enum cpufreq_controller {
     FREQCTL_none, FREQCTL_dom0_kernel, FREQCTL_xen
-- 
2.17.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

WARNING: multiple messages have this Message-ID (diff)
From: Stefano Stabellini <sstabellini@kernel.org>
To: xen-devel@lists.xenproject.org
Cc: Stefano Stabellini <stefanos@xilinx.com>,
	sstabellini@kernel.org, Wei Liu <wl@xen.org>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	George Dunlap <george.dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>,
	Julien Grall <julien.grall@arm.com>,
	Jan Beulich <jbeulich@suse.com>,
	Dario Faggioli <dfaggioli@suse.com>
Subject: [Xen-devel] [PATCH] xen: debug_registers_trap, perf_counters_trap, and "static_partitioning"
Date: Fri, 31 May 2019 16:00:56 -0700	[thread overview]
Message-ID: <20190531230056.14506-1-sstabellini@kernel.org> (raw)
Message-ID: <20190531230056.FRvhlAaGHJFaDacQciragnW3ss8VvIrCATCwp9VJ9dg@z> (raw)

Introduce two global parameters to disable debug registers trapping and
perf counters trapping. They are only safe to use in static partitiong
scenarios where sched=null is used -- vcpu cannot be migrated from one
pcpu to the next.

Introduce a new simple umbrella command line option
"static_partitioning" that enables vwfi=native, sched=null, and also
sets debug_registers_trap and perf_counters_trap to false.

Signed-off-by: Stefano Stabellini <stefanos@xilinx.com>
CC: Julien Grall <julien.grall@arm.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
CC: George Dunlap <George.Dunlap@eu.citrix.com>
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: Tim Deegan <tim@xen.org>
CC: Wei Liu <wl@xen.org>
CC: George Dunlap <george.dunlap@eu.citrix.com>
CC: Dario Faggioli <dfaggioli@suse.com>
---
This is not ideal. The best course of action would be to implement
proper context switching of all the necessary debug and perf counters
registers. This is an imperfect shortcut, which could reasonably be left
out of the upstream tree but I shared it with others for their
convenience.
---
 xen/arch/arm/traps.c    | 26 +++++++++++++++++++++++++-
 xen/common/schedule.c   |  2 +-
 xen/include/xen/sched.h |  1 +
 3 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index 5c18e918b0..d6eaffde23 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -118,6 +118,28 @@ static int __init parse_vwfi(const char *s)
 }
 custom_param("vwfi", parse_vwfi);
 
+static bool debug_registers_trap = true;
+static bool perf_counters_trap = true;
+
+static int __init opt_static_partitioning(const char *s)
+{
+    if ( strcmp(s, "true") && 
+         strcmp(s, "True") &&
+         strcmp(s, "1") )
+        return 0;
+
+    vwfi = NATIVE;
+    debug_registers_trap = false;
+    perf_counters_trap = false;
+    memcpy(opt_sched, "null", 5);
+
+    /* Disable Trap Debug and Performance Monitor now for CPU0 */
+    WRITE_SYSREG(HDCR_TDRA, MDCR_EL2);
+
+    return 0;
+}
+custom_param("static_partitioning", opt_static_partitioning);
+
 register_t get_default_hcr_flags(void)
 {
     return  (HCR_PTW|HCR_BSU_INNER|HCR_AMO|HCR_IMO|HCR_FMO|HCR_VM|
@@ -165,7 +187,9 @@ void init_traps(void)
     WRITE_SYSREG((vaddr_t)hyp_traps_vector, VBAR_EL2);
 
     /* Trap Debug and Performance Monitor accesses */
-    WRITE_SYSREG(HDCR_TDRA|HDCR_TDOSA|HDCR_TDA|HDCR_TPM|HDCR_TPMCR,
+    WRITE_SYSREG(HDCR_TDRA |
+                 (debug_registers_trap ? HDCR_TDOSA|HDCR_TDA : 0) |
+                 (perf_counters_trap ? HDCR_TPM|HDCR_TPMCR : 0),
                  MDCR_EL2);
 
     /* Trap CP15 c15 used for implementation defined registers */
diff --git a/xen/common/schedule.c b/xen/common/schedule.c
index 049f93f7aa..51eb3d770b 100644
--- a/xen/common/schedule.c
+++ b/xen/common/schedule.c
@@ -39,7 +39,7 @@
 #include <xen/err.h>
 
 /* opt_sched: scheduler - default to configured value */
-static char __initdata opt_sched[10] = CONFIG_SCHED_DEFAULT;
+char __initdata opt_sched[10] = CONFIG_SCHED_DEFAULT;
 string_param("sched", opt_sched);
 
 /* if sched_smt_power_savings is set,
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index b73ccbdf3a..c40a1b5dbc 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -906,6 +906,7 @@ static inline bool is_vcpu_online(const struct vcpu *v)
 }
 
 extern bool sched_smt_power_savings;
+extern char opt_sched[10];
 
 extern enum cpufreq_controller {
     FREQCTL_none, FREQCTL_dom0_kernel, FREQCTL_xen
-- 
2.17.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

             reply	other threads:[~2019-05-31 23:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-31 23:00 Stefano Stabellini [this message]
2019-05-31 23:00 ` [Xen-devel] [PATCH] xen: debug_registers_trap, perf_counters_trap, and "static_partitioning" Stefano Stabellini
2019-05-31 23:15 ` Andrew Cooper
2019-05-31 23:15   ` [Xen-devel] " Andrew Cooper
2019-06-01 16:52 ` Julien Grall
2019-06-01 16:52   ` [Xen-devel] " Julien Grall
2019-06-03  9:47 ` Jan Beulich
2019-06-03  9:47   ` [Xen-devel] " Jan Beulich

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=20190531230056.14506-1-sstabellini@kernel.org \
    --to=sstabellini@kernel.org \
    --cc=andrew.cooper3@citrix.com \
    --cc=dfaggioli@suse.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien.grall@arm.com \
    --cc=konrad.wilk@oracle.com \
    --cc=stefanos@xilinx.com \
    --cc=tim@xen.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.