lkml.org 
[lkml]   [2022]   [Nov]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] drivers/xen/hypervisor: Expose VM SIF flags to userspace
From

On 11/29/22 10:00 AM, Per Bilse wrote:
>
> +static ssize_t flags_show(struct hyp_sysfs_attr *attr, char *buffer)
> +{
> + static char const *const sifstr[SIFN_NUM_SIFN] = {
> + [SIFN_PRIV] = "privileged",
> + [SIFN_INIT] = "initdomain",
> + [SIFN_MULTI] = "multiboot",
> + [SIFN_PFN] = "mod_start_pfn",
> + [SIFN_VIRT] = "virtmap"
> + };
> + unsigned sifnum, sifmask;
> + ssize_t ret = 0;
> +
> + sifmask = ~(~0U << SIFN_NUM_SIFN); // ...0000111...
> + if (xen_domain() && (xen_start_flags & sifmask) != 0) {
> + for (sifnum = 0; sifnum != SIFN_NUM_SIFN; sifnum++) {
> + if ((xen_start_flags & (1<<sifnum)) != 0)
> + ret += sprintf(buffer+ret, "%s ", sifstr[sifnum]);
> + }
> + buffer[ret-1] = '\n';
> + }
> + return ret;
> +}


Why not simply show unprocessed xen_start_flags as a hex value?


-boris

\
 
 \ /
  Last update: 2022-11-29 17:30    [W:1.373 / U:0.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site