mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-05-28 18:04:23 +00:00
DM NPK: use a slice (8 masters) as the minimal unit for NPK virt
To align with the configuration of the HOST tool, the SW masters are organized in slices of 8 masters each. The slice is also the minimal unit to allocate the SW masters for each UOS. The patch is to update the parameter checking function. Tracked-On: #1138 Signed-off-by: Zhi Jin <zhi.jin@intel.com> Reviewed-by: Chen Gang <gang.c.chen@intel.com>
This commit is contained in:
parent
d8c97c1b2d
commit
9a276592fb
@ -159,11 +159,11 @@ static inline uint32_t *offset2reg(uint64_t offset)
|
||||
return reg;
|
||||
}
|
||||
|
||||
static inline int valid_param(int m_off, int m_num)
|
||||
static inline int valid_param(uint32_t m_off, uint32_t m_num)
|
||||
{
|
||||
/* 256-aligned, no less than 256, no overflow */
|
||||
if (!(m_off & 0xFF) && !(m_num & 0xFF) && (m_off >> 8) > 0
|
||||
&& (m_num >> 8) > 0 && m_off + m_num <= NPK_SW_MSTR_NUM)
|
||||
/* 8-aligned, no less than 8, no overflow */
|
||||
if (((m_off & 0x7U) == 0) && ((m_num & 0x7U) == 0) && (m_off > 0x7U)
|
||||
&& (m_num > 0x7U) && (m_off + m_num <= NPK_SW_MSTR_NUM))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
@ -177,11 +177,12 @@ static inline int valid_param(int m_off, int m_num)
|
||||
*/
|
||||
static int pci_npk_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
||||
{
|
||||
int i, b, s, f, fd, ret, m_off, m_num, error = -1;
|
||||
int i, b, s, f, fd, ret, error = -1;
|
||||
DIR *dir;
|
||||
struct dirent *dent;
|
||||
char name[PATH_MAX];
|
||||
uint8_t h_cfg[PCI_REGMAX + 1];
|
||||
uint32_t m_off, m_num;
|
||||
uint64_t sw_bar_base;
|
||||
struct npk_reg_default_val *d;
|
||||
|
||||
@ -210,7 +211,7 @@ static int pci_npk_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
||||
*/
|
||||
|
||||
/* get the master offset and the number for this guest */
|
||||
if (opts == NULL || sscanf(opts, "%d/%d", &m_off, &m_num) != 2
|
||||
if ((opts == NULL) || (sscanf(opts, "%u/%u", &m_off, &m_num) != 2)
|
||||
|| !valid_param(m_off, m_num)) {
|
||||
m_off = 256;
|
||||
m_num = 256;
|
||||
|
Loading…
Reference in New Issue
Block a user