summaryrefslogtreecommitdiff
path: root/big-little/virtualisor/virt_context.c
diff options
context:
space:
mode:
Diffstat (limited to 'big-little/virtualisor/virt_context.c')
-rw-r--r--big-little/virtualisor/virt_context.c355
1 files changed, 178 insertions, 177 deletions
diff --git a/big-little/virtualisor/virt_context.c b/big-little/virtualisor/virt_context.c
index 5472587..def3551 100644
--- a/big-little/virtualisor/virt_context.c
+++ b/big-little/virtualisor/virt_context.c
@@ -18,7 +18,7 @@
* contributors may be used to endorse or promote products
* derived from this software without specific prior written
* permission.
- */
+ */
#include "virtualisor.h"
#include "misc.h"
@@ -38,100 +38,100 @@ extern cache_stats cm_op_stats[NUM_CPUS][MAX_CACHE_LEVELS];
*/
void SaveVirtualisor(unsigned first_cpu)
{
- unsigned len = 0, ctr = 0, cpu_id = read_cpuid(), cpu_no = PART_NO(read_midr());
- unsigned cluster_id = read_clusterid(), index = 0, vd_len = 0, rc = 0;
- mem_trap_data *s2_td = &s2_trap_section$$Base;
- unsigned long long *cd_ptr = 0x0;
- unsigned *periph_addr = 0x0;
- virt_descriptor *vd_array = &virt_desc_section$$Base;
- unsigned (*handler) (unsigned, unsigned) = 0x0, sibling;
-
- /* Find our brother from another mother */
- sibling = find_sibling_cpu();
-
- if (cluster_id == host_cluster) {
- /*
- * Since there is only one second stage translation table, its
- * safe to assume that only one cpu (first_cpu) should save &
- * restore the context.
- */
- len = (unsigned)&s2_trap_section$$Length;
- if (cpu_id == first_cpu) {
- /* Iterate through the array of 2nd stage translation traps */
- for (ctr = 0; ctr < (len / sizeof(mem_trap_data)); ctr++) {
- if (s2_td[ctr].valid
- && s2_td[ctr].cluster_id == cluster_id) {
-
- /*
- * Save the current descriptor and restore the
- * previous. Need not worry about synchronisation
- * issues, as the existing entry was causing
- * translation faults. The TLB never caches fault
- * generating translations.
- */
- cd_ptr =
- &((unsigned long long
- *)((unsigned)(&s2_td[ctr].
- table)[0]))[s2_td[ctr].
- index];
- s2_td[ctr].cur_desc = *cd_ptr;
- *cd_ptr = s2_td[ctr].prev_desc;
- periph_addr = (unsigned *) cd_ptr;
- dsb();
- inv_tlb_mva((unsigned *) periph_addr[0]);
- inv_bpred_all();
- }
- }
- }
-
- /* Save the HYP trap registers for this cpu */
- host_trap_regs[cpu_id].hcr = read_hcr();
- host_trap_regs[cpu_id].hdcr = read_hdcr();
- host_trap_regs[cpu_id].hcptr = read_hcptr();
- host_trap_regs[cpu_id].hstr = read_hstr();
-
- if(cmop_debug) {
- /* Print Cache maintenance statistics */
- for (ctr = 0; ctr < MAX_CACHE_LEVELS; ctr++) {
- printf("Cache Level %d", ctr);
- printf(" : Partial ops=0x%x",
- cm_op_stats[cpu_id][ctr].part_cmop_cnt);
- printf(" : Complete ops=0x%x",
- cm_op_stats[cpu_id][ctr].cmpl_cmop_cnt);
- printf("\n");
- }
- }
-
- }
-
- /*
- * Call any cpu specific save routines (if any)
- */
- vd_len = (unsigned)&virt_desc_section$$Length;
- for (index = 0; index < (vd_len / sizeof(virt_descriptor)); index++) {
-
- if (cpu_no == vd_array[index].cpu_no) {
- handler = vd_array[index].trap_save;
- if(handler) {
- rc = handler(first_cpu, sibling);
- if (rc) {
- printf("%s: failed on cpu%d \n",
- __FUNCTION__,
- cpu_no);
- goto out;
- }
- }
- }
- }
+ unsigned len = 0, ctr = 0, cpu_id = read_cpuid(), cpu_no =
+ PART_NO(read_midr());
+ unsigned cluster_id = read_clusterid(), index = 0, vd_len = 0, rc = 0;
+ mem_trap_data *s2_td = &s2_trap_section$$Base;
+ unsigned long long *cd_ptr = 0x0;
+ unsigned *periph_addr = 0x0;
+ virt_descriptor *vd_array = &virt_desc_section$$Base;
+ unsigned (*handler) (unsigned, unsigned) = 0x0, sibling;
+
+ /* Find our brother from another mother */
+ sibling = find_sibling_cpu();
+
+ if (cluster_id == host_cluster) {
+ /*
+ * Since there is only one second stage translation table, its
+ * safe to assume that only one cpu (first_cpu) should save &
+ * restore the context.
+ */
+ len = (unsigned)&s2_trap_section$$Length;
+ if (cpu_id == first_cpu) {
+ /* Iterate through the array of 2nd stage translation traps */
+ for (ctr = 0; ctr < (len / sizeof(mem_trap_data));
+ ctr++) {
+ if (s2_td[ctr].valid
+ && s2_td[ctr].cluster_id == cluster_id) {
+
+ /*
+ * Save the current descriptor and restore the
+ * previous. Need not worry about synchronisation
+ * issues, as the existing entry was causing
+ * translation faults. The TLB never caches fault
+ * generating translations.
+ */
+ cd_ptr =
+ &((unsigned long long
+ *)((unsigned)(&s2_td[ctr].table)
+ [0]))[s2_td[ctr].index];
+ s2_td[ctr].cur_desc = *cd_ptr;
+ *cd_ptr = s2_td[ctr].prev_desc;
+ periph_addr = (unsigned *)cd_ptr;
+ dsb();
+ inv_tlb_mva((unsigned *)periph_addr[0]);
+ inv_bpred_all();
+ }
+ }
+ }
+
+ /* Save the HYP trap registers for this cpu */
+ host_trap_regs[cpu_id].hcr = read_hcr();
+ host_trap_regs[cpu_id].hdcr = read_hdcr();
+ host_trap_regs[cpu_id].hcptr = read_hcptr();
+ host_trap_regs[cpu_id].hstr = read_hstr();
+
+ if (cmop_debug) {
+ /* Print Cache maintenance statistics */
+ for (ctr = 0; ctr < MAX_CACHE_LEVELS; ctr++) {
+ printf("Cache Level %d", ctr);
+ printf(" : Partial ops=0x%x",
+ cm_op_stats[cpu_id][ctr].part_cmop_cnt);
+ printf(" : Complete ops=0x%x",
+ cm_op_stats[cpu_id][ctr].cmpl_cmop_cnt);
+ printf("\n");
+ }
+ }
+
+ }
+
+ /*
+ * Call any cpu specific save routines (if any)
+ */
+ vd_len = (unsigned)&virt_desc_section$$Length;
+ for (index = 0; index < (vd_len / sizeof(virt_descriptor)); index++) {
+
+ if (cpu_no == vd_array[index].cpu_no) {
+ handler = vd_array[index].trap_save;
+ if (handler) {
+ rc = handler(first_cpu, sibling);
+ if (rc) {
+ printf("%s: failed on cpu%d \n",
+ __FUNCTION__, cpu_no);
+ goto out;
+ }
+ }
+ }
+ }
out:
- if (rc) {
- printf("%s: Failed : Cpu%d : Host=0x%x : Target=0x%x\n ",
- __FUNCTION__, cpu_id, cpu_no, sibling);
- panic();
- }
+ if (rc) {
+ printf("%s: Failed : Cpu%d : Host=0x%x : Target=0x%x\n ",
+ __FUNCTION__, cpu_id, cpu_no, sibling);
+ panic();
+ }
- return;
+ return;
}
/*
@@ -141,92 +141,93 @@ void SaveVirtualisor(unsigned first_cpu)
*/
void RestoreVirtualisor(unsigned first_cpu)
{
- unsigned len = 0, ctr = 0, cpu_id = read_cpuid(), cpu_no = PART_NO(read_midr());
- unsigned cluster_id = read_clusterid(), index = 0, vd_len = 0, rc = 0;
- mem_trap_data *s2_td = &s2_trap_section$$Base;
- unsigned long long *cd_ptr = 0x0;
- unsigned *periph_addr = 0x0;
- virt_descriptor *vd_array = &virt_desc_section$$Base;
- unsigned (*handler) (unsigned, unsigned) = 0x0, sibling;
-
- /* Find our brother from another mother */
- sibling = find_sibling_cpu();
-
- if (cluster_id == host_cluster) {
- /*
- * Since there is only one second stage translation table, its
- * safe to assume that only one cpu (first_cpu) should save &
- * restore the context.
- */
- len = (unsigned)&s2_trap_section$$Length;
- if (cpu_id == first_cpu) {
- /* Iterate through the array of 2nd stage translation traps */
- for (ctr = 0; ctr < (len / sizeof(mem_trap_data)); ctr++) {
- if (s2_td[ctr].valid
- && s2_td[ctr].cluster_id == cluster_id) {
- /*
- * Restore the current descriptor and save the previous
- */
- cd_ptr =
- &((unsigned long long
- *)((unsigned)((&s2_td[ctr].
- table)[0])))[s2_td[ctr].
- index];
- s2_td[ctr].prev_desc = *cd_ptr;
- *cd_ptr = s2_td[ctr].cur_desc;
- periph_addr = (unsigned *) cd_ptr;
- dsb();
- inv_tlb_mva((unsigned *) periph_addr[0]);
- inv_bpred_all();
- }
- }
- }
-
- /* Now restore the virtualised ID registers for this cpu */
- write_vmidr(host_virt_regs[cpu_id].midr);
- write_vmpidr(host_virt_regs[cpu_id].mpidr);
-
- /* Restore the HYP trap registers for this cpu */
- write_hcr(host_trap_regs[cpu_id].hcr);
- write_hdcr(host_trap_regs[cpu_id].hdcr);
- write_hcptr(host_trap_regs[cpu_id].hcptr);
- write_hstr(host_trap_regs[cpu_id].hstr);
-
- if(cmop_debug) {
- /* Resetting Cache maintenance statistics */
- for (ctr = 0; ctr < MAX_CACHE_LEVELS; ctr++) {
- cm_op_stats[cpu_id][ctr].part_cmop_cnt = 0;
- cm_op_stats[cpu_id][ctr].cmpl_cmop_cnt = 0;
- }
- }
- }
-
- /*
- * Call any cpu specific restore routines (if any)
- */
- vd_len = (unsigned)&virt_desc_section$$Length;
- for (index = 0; index < (vd_len / sizeof(virt_descriptor)); index++) {
-
- if (cpu_no == vd_array[index].cpu_no) {
- handler = vd_array[index].trap_restore;
- if(handler) {
- rc = handler(first_cpu, sibling);
- if (rc) {
- printf("%s: failed on cpu%d \n",
- __FUNCTION__,
- cpu_no);
- goto out;
- }
- }
- }
- }
+ unsigned len = 0, ctr = 0, cpu_id = read_cpuid(), cpu_no =
+ PART_NO(read_midr());
+ unsigned cluster_id = read_clusterid(), index = 0, vd_len = 0, rc = 0;
+ mem_trap_data *s2_td = &s2_trap_section$$Base;
+ unsigned long long *cd_ptr = 0x0;
+ unsigned *periph_addr = 0x0;
+ virt_descriptor *vd_array = &virt_desc_section$$Base;
+ unsigned (*handler) (unsigned, unsigned) = 0x0, sibling;
+
+ /* Find our brother from another mother */
+ sibling = find_sibling_cpu();
+
+ if (cluster_id == host_cluster) {
+ /*
+ * Since there is only one second stage translation table, its
+ * safe to assume that only one cpu (first_cpu) should save &
+ * restore the context.
+ */
+ len = (unsigned)&s2_trap_section$$Length;
+ if (cpu_id == first_cpu) {
+ /* Iterate through the array of 2nd stage translation traps */
+ for (ctr = 0; ctr < (len / sizeof(mem_trap_data));
+ ctr++) {
+ if (s2_td[ctr].valid
+ && s2_td[ctr].cluster_id == cluster_id) {
+ /*
+ * Restore the current descriptor and save the previous
+ */
+ cd_ptr =
+ &((unsigned long long
+ *)((unsigned)((&s2_td[ctr].table)
+ [0])))[s2_td
+ [ctr].index];
+ s2_td[ctr].prev_desc = *cd_ptr;
+ *cd_ptr = s2_td[ctr].cur_desc;
+ periph_addr = (unsigned *)cd_ptr;
+ dsb();
+ inv_tlb_mva((unsigned *)periph_addr[0]);
+ inv_bpred_all();
+ }
+ }
+ }
+
+ /* Now restore the virtualised ID registers for this cpu */
+ write_vmidr(host_virt_regs[cpu_id].midr);
+ write_vmpidr(host_virt_regs[cpu_id].mpidr);
+
+ /* Restore the HYP trap registers for this cpu */
+ write_hcr(host_trap_regs[cpu_id].hcr);
+ write_hdcr(host_trap_regs[cpu_id].hdcr);
+ write_hcptr(host_trap_regs[cpu_id].hcptr);
+ write_hstr(host_trap_regs[cpu_id].hstr);
+
+ if (cmop_debug) {
+ /* Resetting Cache maintenance statistics */
+ for (ctr = 0; ctr < MAX_CACHE_LEVELS; ctr++) {
+ cm_op_stats[cpu_id][ctr].part_cmop_cnt = 0;
+ cm_op_stats[cpu_id][ctr].cmpl_cmop_cnt = 0;
+ }
+ }
+ }
+
+ /*
+ * Call any cpu specific restore routines (if any)
+ */
+ vd_len = (unsigned)&virt_desc_section$$Length;
+ for (index = 0; index < (vd_len / sizeof(virt_descriptor)); index++) {
+
+ if (cpu_no == vd_array[index].cpu_no) {
+ handler = vd_array[index].trap_restore;
+ if (handler) {
+ rc = handler(first_cpu, sibling);
+ if (rc) {
+ printf("%s: failed on cpu%d \n",
+ __FUNCTION__, cpu_no);
+ goto out;
+ }
+ }
+ }
+ }
out:
- if (rc) {
- printf("%s: Failed : Cpu%d : Host=0x%x : Target=0x%x\n ",
- __FUNCTION__, cpu_id, cpu_no, sibling);
- panic();
- }
+ if (rc) {
+ printf("%s: Failed : Cpu%d : Host=0x%x : Target=0x%x\n ",
+ __FUNCTION__, cpu_id, cpu_no, sibling);
+ panic();
+ }
- return;
+ return;
}