diff options
author | klu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-01-04 09:21:03 +0000 |
---|---|---|
committer | klu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-01-04 09:21:03 +0000 |
commit | f53a07320e7021b5a80973cc7b265bd8ce5caf40 (patch) | |
tree | fb4714a1a46f65ee5e232a359768b9bb13b54290 /EdkModulePkg/Universal | |
parent | 3088e811376d8893366c0a48d493b480e3e96fda (diff) | |
download | edk2-f53a07320e7021b5a80973cc7b265bd8ce5caf40.tar.gz edk2-f53a07320e7021b5a80973cc7b265bd8ce5caf40.tar.bz2 edk2-f53a07320e7021b5a80973cc7b265bd8ce5caf40.zip |
Volatile variable is read-only in runtime.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2170 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkModulePkg/Universal')
-rw-r--r-- | EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c | 61 | ||||
-rw-r--r-- | EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 64 |
2 files changed, 69 insertions, 56 deletions
diff --git a/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c b/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c index b44da1c474..0eef1acfc4 100644 --- a/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c +++ b/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c @@ -506,38 +506,40 @@ Returns: if (Status == EFI_INVALID_PARAMETER) {
return Status;
- }
- //
- // The size of the VariableName, including the Unicode Null in bytes plus
- // the DataSize is limited to maximum size of MAX_VARIABLE_SIZE (1024) bytes.
- //
- else if (sizeof (VARIABLE_HEADER) + (ArrayLength (VariableName) + DataSize) > MAX_VARIABLE_SIZE) {
+ } else if (!EFI_ERROR (Status) && Variable.Volatile && EfiAtRuntime()) {
+ //
+ // If EfiAtRuntime and the variable is Volatile and Runtime Access,
+ // the volatile is ReadOnly, and SetVariable should be aborted and
+ // return EFI_WRITE_PROTECTED.
+ //
+ return EFI_WRITE_PROTECTED;
+ } else if (sizeof (VARIABLE_HEADER) + (ArrayLength (VariableName) + DataSize) > MAX_VARIABLE_SIZE) {
+ //
+ // The size of the VariableName, including the Unicode Null in bytes plus
+ // the DataSize is limited to maximum size of MAX_VARIABLE_SIZE (1024) bytes.
+ //
return EFI_INVALID_PARAMETER;
- }
- //
- // Make sure if runtime bit is set, boot service bit is set also
- //
- else if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == EFI_VARIABLE_RUNTIME_ACCESS
+ } else if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == EFI_VARIABLE_RUNTIME_ACCESS
) {
+ //
+ // Make sure if runtime bit is set, boot service bit is set also
+ //
return EFI_INVALID_PARAMETER;
- }
- //
- // Runtime but Attribute is not Runtime
- //
- else if (EfiAtRuntime () && Attributes && !(Attributes & EFI_VARIABLE_RUNTIME_ACCESS)) {
+ } else if (EfiAtRuntime () && Attributes && !(Attributes & EFI_VARIABLE_RUNTIME_ACCESS)) {
+ //
+ // Runtime but Attribute is not Runtime
+ //
return EFI_INVALID_PARAMETER;
- }
- //
- // Cannot set volatile variable in Runtime
- //
- else if (EfiAtRuntime () && Attributes && !(Attributes & EFI_VARIABLE_NON_VOLATILE)) {
+ } else if (EfiAtRuntime () && Attributes && !(Attributes & EFI_VARIABLE_NON_VOLATILE)) {
+ //
+ // Cannot set volatile variable in Runtime
+ //
return EFI_INVALID_PARAMETER;
- }
- //
- // Setting a data variable with no access, or zero DataSize attributes
- // specified causes it to be deleted.
- //
- else if (DataSize == 0 || Attributes == 0) {
+ } else if (DataSize == 0 || (Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == 0) {
+ //
+ // Setting a data variable with no access, or zero DataSize attributes
+ // specified causes it to be deleted.
+ //
if (!EFI_ERROR (Status)) {
Variable.CurrPtr->State &= VAR_DELETED;
return EFI_SUCCESS;
@@ -692,6 +694,11 @@ Returns: // Make sure RT Attribute is set if we are in Runtime phase.
//
return EFI_INVALID_PARAMETER;
+ } else if (EfiAtRuntime () && Attributes && !(Attributes & EFI_VARIABLE_NON_VOLATILE)) {
+ //
+ // Cannot Query volatile variable in Runtime
+ //
+ return EFI_INVALID_PARAMETER;
}
if((Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) {
diff --git a/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c index 5d631a5368..f59d2a3969 100644 --- a/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -810,39 +810,45 @@ Returns: if (Status == EFI_INVALID_PARAMETER) {
return Status;
- }
- //
- // The size of the VariableName, including the Unicode Null in bytes plus
- // the DataSize is limited to maximum size of MAX_VARIABLE_SIZE (1024) bytes.
- //
- else if ((DataSize > MAX_VARIABLE_SIZE) ||
- (sizeof (VARIABLE_HEADER) + ArrayLength (VariableName) + DataSize > MAX_VARIABLE_SIZE)) {
+ } else if (!EFI_ERROR (Status) && Variable.Volatile && EfiAtRuntime()) {
+ //
+ // If EfiAtRuntime and the variable is Volatile and Runtime Access,
+ // the volatile is ReadOnly, and SetVariable should be aborted and
+ // return EFI_WRITE_PROTECTED.
+ //
+ return EFI_WRITE_PROTECTED;
+ } else if (sizeof (VARIABLE_HEADER) + ArrayLength (VariableName) + DataSize > MAX_VARIABLE_SIZE) {
+ //
+ // The size of the VariableName, including the Unicode Null in bytes plus
+ // the DataSize is limited to maximum size of MAX_VARIABLE_SIZE (1024) bytes.
+ //
return EFI_INVALID_PARAMETER;
- }
- //
- // Make sure if runtime bit is set, boot service bit is set also
- //
- else if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == EFI_VARIABLE_RUNTIME_ACCESS
- ) {
+ } else if (Attributes == EFI_VARIABLE_NON_VOLATILE) {
+ //
+ // Make sure not only EFI_VARIABLE_NON_VOLATILE is set
+ //
return EFI_INVALID_PARAMETER;
- }
- //
- // Runtime but Attribute is not Runtime
- //
- else if (EfiAtRuntime () && Attributes && !(Attributes & EFI_VARIABLE_RUNTIME_ACCESS)) {
+ } else if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) ==
+ EFI_VARIABLE_RUNTIME_ACCESS) {
+ //
+ // Make sure if runtime bit is set, boot service bit is set also
+ //
return EFI_INVALID_PARAMETER;
- }
- //
- // Cannot set volatile variable in Runtime
- //
- else if (EfiAtRuntime () && Attributes && !(Attributes & EFI_VARIABLE_NON_VOLATILE)) {
+ } else if (EfiAtRuntime () && Attributes && !(Attributes & EFI_VARIABLE_RUNTIME_ACCESS)) {
+ //
+ // Runtime but Attribute is not Runtime
+ //
return EFI_INVALID_PARAMETER;
- }
- //
- // Setting a data variable with no access, or zero DataSize attributes
- // specified causes it to be deleted.
- //
- else if (DataSize == 0 || Attributes == 0) {
+ } else if (EfiAtRuntime () && Attributes && !(Attributes & EFI_VARIABLE_NON_VOLATILE)) {
+ //
+ // Cannot set volatile variable in Runtime
+ //
+ return EFI_INVALID_PARAMETER;
+ } else if (DataSize == 0 || (Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == 0) {
+ //
+ // Setting a data variable with no access, or zero DataSize attributes
+ // specified causes it to be deleted.
+ //
if (!EFI_ERROR (Status)) {
State = Variable.CurrPtr->State;
State &= VAR_DELETED;
|