minor issue with XPlmi_GetIpiReqType
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 1.2k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
issue information: Xilinx source edited using Vitis 2022.1, plm firmware template, libsrc/xilplmi_v1.6/xplmi_ipi.c line 568. The issue was found while reading the code.
Context: XPlmi_GetIpiReqType extracts a bit to know if the IPI command has to be processed in a secured way.
The mask is IPI_CMD_HDR_SECURE_BIT_MASK and the test is against XPLMI_CMD_SECURE.
IPI_CMD_HDR_SECURE_BIT_MASK is 0x1000000U (see xplmi_ipi.h)
XPLMI_CMD_SECURE is 0x0U and the opposite XPLMI_CMD_NON_SECURE 0x1U (see xplmi.h)
Fortunately the test is against the value 0 by using XPLMI_CMD_SECURE. The coding error here is that a test against XPLMI_CMD_NON_SECURE would always return 0 (input value mask 0x1000000U against value "1" ).
I suggest correcting this to avoid ambiguity while trying to understand this piece of code.
Several solution exist such as shifting the input value before testing or simply testing against the "0" value without using the macro.
Extract of code
static u32 XPlmi_GetIpiReqType(u32 CmdId, u32 SrcIndex)
{
u32 CmdPerm = CmdId & IPI_CMD_HDR_SECURE_BIT_MASK;
volatile u32 ChannelPerm = XPLMI_CMD_NON_SECURE;
volatile u32 ChannelPermTmp = XPLMI_CMD_NON_SECURE;
u32 IpiReqType = XPLMI_CMD_NON_SECURE;
/* Treat command as non-secure if Command type is non-secure */
if (XPLMI_CMD_SECURE != CmdPerm) {
goto END;
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at XPlmi_GetIpiReqType in libsrc/xilplmi_v1.6/xplmi_ipi.c around line 568, then read IPI_CMD_HDR_SECURE_BIT_MASK in xplmi_ipi.h and XPLMI_CMD_SECURE/XPLMI_CMD_NON_SECURE in xplmi.h. Clarify the masked-bit comparison without changing its intended behavior. Done when the condition is unambiguous and the relevant firmware tests or build complete successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100