New flag: disable_global_lock - Disables global lock usage in guest code.
This commit is contained in:
@@ -28,6 +28,10 @@ DEFINE_bool(trace_function_references, false,
|
||||
DEFINE_bool(trace_function_data, false,
|
||||
"Generate tracing for function result data.");
|
||||
|
||||
DEFINE_bool(
|
||||
disable_global_lock, false,
|
||||
"Disables global lock usage in guest code. Does not affect host code.");
|
||||
|
||||
DEFINE_bool(validate_hir, false,
|
||||
"Perform validation checks on the HIR during compilation.");
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@ DECLARE_bool(trace_function_coverage);
|
||||
DECLARE_bool(trace_function_references);
|
||||
DECLARE_bool(trace_function_data);
|
||||
|
||||
DECLARE_bool(disable_global_lock);
|
||||
|
||||
DECLARE_bool(validate_hir);
|
||||
|
||||
DECLARE_uint64(break_on_instruction);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "xenia/cpu/ppc/ppc_emit-private.h"
|
||||
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/cpu/cpu_flags.h"
|
||||
#include "xenia/cpu/ppc/ppc_context.h"
|
||||
#include "xenia/cpu/ppc/ppc_frontend.h"
|
||||
#include "xenia/cpu/ppc/ppc_hir_builder.h"
|
||||
@@ -725,10 +726,14 @@ int InstrEmit_mtmsr(PPCHIRBuilder& f, const InstrData& i) {
|
||||
f.ZeroExtend(f.ZeroExtend(f.LoadGPR(i.X.RT), INT64_TYPE), INT64_TYPE));
|
||||
if (i.X.RT == 13) {
|
||||
// iff storing from r13 we are taking a lock (disable interrupts).
|
||||
f.CallExtern(f.builtins()->enter_global_lock);
|
||||
if (!FLAGS_disable_global_lock) {
|
||||
f.CallExtern(f.builtins()->enter_global_lock);
|
||||
}
|
||||
} else {
|
||||
// Otherwise we are restoring interrupts (probably).
|
||||
f.CallExtern(f.builtins()->leave_global_lock);
|
||||
if (!FLAGS_disable_global_lock) {
|
||||
f.CallExtern(f.builtins()->leave_global_lock);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
@@ -746,10 +751,14 @@ int InstrEmit_mtmsrd(PPCHIRBuilder& f, const InstrData& i) {
|
||||
f.ZeroExtend(f.LoadGPR(i.X.RT), INT64_TYPE));
|
||||
if (i.X.RT == 13) {
|
||||
// iff storing from r13 we are taking a lock (disable interrupts).
|
||||
f.CallExtern(f.builtins()->enter_global_lock);
|
||||
if (!FLAGS_disable_global_lock) {
|
||||
f.CallExtern(f.builtins()->enter_global_lock);
|
||||
}
|
||||
} else {
|
||||
// Otherwise we are restoring interrupts (probably).
|
||||
f.CallExtern(f.builtins()->leave_global_lock);
|
||||
if (!FLAGS_disable_global_lock) {
|
||||
f.CallExtern(f.builtins()->leave_global_lock);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
|
||||
@@ -702,6 +702,9 @@ int InstrEmit_stdcx(PPCHIRBuilder& f, const InstrData& i) {
|
||||
// NOTE: we assume we are within a global lock.
|
||||
// As we have been exclusively executing this entire time, we assume that no
|
||||
// one else could have possibly touched the memory and must always succeed.
|
||||
// We use atomic compare exchange here to support reserved load/store without
|
||||
// being under the global lock (flag disable_global_lock - see mtmsr/mtmsrd).
|
||||
// This will always succeed if under the global lock, however.
|
||||
|
||||
Value* ea = CalculateEA_0(f, i.X.RA, i.X.RB);
|
||||
Value* rt = f.ByteSwap(f.LoadGPR(i.X.RT));
|
||||
@@ -732,6 +735,9 @@ int InstrEmit_stwcx(PPCHIRBuilder& f, const InstrData& i) {
|
||||
// NOTE: we assume we are within a global lock.
|
||||
// As we have been exclusively executing this entire time, we assume that no
|
||||
// one else could have possibly touched the memory and must always succeed.
|
||||
// We use atomic compare exchange here to support reserved load/store without
|
||||
// being under the global lock (flag disable_global_lock - see mtmsr/mtmsrd).
|
||||
// This will always succeed if under the global lock, however.
|
||||
|
||||
Value* ea = CalculateEA_0(f, i.X.RA, i.X.RB);
|
||||
Value* rt = f.ByteSwap(f.Truncate(f.LoadGPR(i.X.RT), INT32_TYPE));
|
||||
|
||||
Reference in New Issue
Block a user