-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: check guest_id param passed when recieving SMC from NW #7189
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For commit "core: arm: add guest id check at VM creation": maybe start the commit message with the last sentence, e.g. rephrased here:
Forbid creation of non-secure world guests using the hypervisor ID (0)
that is reserved.
Normal world calls ...
For commit "core: arm: pass guest ID to SMC_ENABLE_ASYNC_NOTIF":
commit message could be shorten IMHO and deserves a Fixes:
tag;,e.g.:
Set guest ID in NOTIF_EVENT_STARTED notification that was missing
causing a panic (segfault or assertion error) in get_notif_data().
Fixes: d237e616e155 ("core: make generic notifications virtualization-aware")
S-o-b: ...
Here's an attempt at taking care of the assert in |
Thanks @jenswi-linaro. Tested. Works like a charm. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please squash in the updates on the first two commits. You'll need to do a git push -f
to update the pull request.
core/kernel/notif_default.c
Outdated
uint32_t old_itr_status = 0; | ||
struct itr_chip *itr_chip = interrupt_get_main_chip(); | ||
|
||
assert(value <= NOTIF_ASYNC_VALUE_MAX && !guest_id); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this duplicated blank line that checkpatch complains over, I must have added it by mistake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted.
44f1f68
to
944f1ed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you squash the fixup in commit "core: arm: guest ID test for notif and VM creation" info each of the related 2 previous commits of your series?
Acked-by: Etienne Carriere <[email protected]>
for the series with the minor comments in "core: notif_default: support ns-virtualization" addressed.
ae0530f
to
dbbdf7a
Compare
Please fix the checkpatch issues. The |
dbbdf7a
to
8088154
Compare
You can run checkpatch on the patches in your tree with: ./scripts/checkpatch.sh github/master.. assuming that the name of the remote is |
8088154
to
c54cc2a
Compare
Sorry, overlooked the second commit :) |
These should be fixed:
|
c54cc2a
to
a02c40b
Compare
Noted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yuvraj1803 , could you discard commit "core: arm: add guest id check at VM creation"
and have all changes related to virt_guest_created()
into commit "core: arm: guest ID test for notif and VM creation".
core/kernel/notif_default.c
Outdated
static bitstr_t bit_decl(notif_alloc_values, NOTIF_ASYNC_VALUE_MAX + 1); | ||
struct notif_vm_bitmap { | ||
bool alloc_values_inited; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could remove this empty line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. There was a warning in checkpatch that was complaining about there not being an empty line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a02c40b
to
37e5be4
Compare
@etienne-lms done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For commit "core: notif_default: support ns-virtualization":
@yuvraj1803 I think you should add your Signed-off-of tag for this patch, next to Jens' one, since it's part of your P-R (see checkpatch complaint about author's S-o-b tag absence).
With that addressed: Reviewed-by: Etienne Carriere <[email protected]>
for the 3 commits.
The other checkpatch warnings around bit_decl()
are false positive.
For commit "core: arm: pass guest ID to SMC_ENABLE_ASYNC_NOTIF", please remove
With that fixed please apply: |
37e5be4
to
dd127cb
Compare
Noted. Thanks @etienne-lms |
Changes made, @jenswi-linaro. |
Maybe rebasing the series will address the 'failing CI / make check' issue. |
dd127cb
to
565396f
Compare
Thanks @etienne-lms |
@yuvraj1803 please add @etienne-lms' |
notif_deliver_atomic_event() expects guest_id which is used to retrieve struct guest_partition* from virt_get_guest(). The guest_id passed is static (0), which causes trouble when OPTEE_SMC_ENABLE_ASYNC_NOTIF comes from a guest. When this happens, virt_get_guest() returns NULL which fails the assertion in get_notif_data() which exclusively checks for CONFIG_NS_VIRTUALIZATION. Signed-off-by: Yuvraj Sakshith <[email protected]> Reviewed-by: Jens Wiklander <[email protected]> Reviewed-by: Etienne Carriere <[email protected]>
Block normal world from calling OPTEE_SMC_VM_CREATED with reserved hypervisor client-id (0) as VMID parameter. Normal world calls OPTEE_SMC_VM_CREATED with guest VMID in a1 and HYP_CLNT_ID in a7. This eventually leads to copying of __data_start to __data_end from the default partition to the guest's MMU partition. Everything goes well until normal world passes HYP_CLNT_ID into a1 which goes unchecked in OPTEE. When the "second VM" is created from normal world, the first VM's MMU partition's __data_start is copied into the new VM's MMU partition which eventually breaks the bpool freelist pointers. This can deliberately be used by normal world to put OP-TEE into panic. Set guest ID when NOTIF_EVENT_STARTED is called preventing assetion failure in get_notif_data(). Fixes: d237e61 ("core: make generic notifications virtualization-aware") Signed-off-by: Yuvraj Sakshith <[email protected]> Reviewed-by: Jens Wiklander <[email protected]> Reviewed-by: Etienne Carriere <[email protected]>
Add support for CFG_NS_VIRTUALIZATION=y in the default notification implementation used with the SMC ABI. virt_add_guest_spec_data() is used to add struct notif_vm_bitmap for bookkeeping per guest, similarly to the implementation for the FF-A ABI. This takes care of and removes the assert for "!guest" in notif_send_async(). Signed-off-by: Jens Wiklander <[email protected]> Signed-off-by: Yuvraj Sakshith <[email protected]> Tested-by: Yuvraj Sakshith <[email protected]> Reviewed-by: Etienne Carriere <[email protected]>
565396f
to
c4223af
Compare
Checked. Thanks! @jforissier |
This was my first ever contribution. Thanks for your patience and support :) @jenswi-linaro @etienne-lms @jforissier |
Certain SMCs such as OPTEE_SMC_VM_CREATED can send OPTEE to panic if guest ID passed is 0.
P.S. sorry for the second PR, there was something really wrong with my branch.