All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "Jürgen Groß" <jgross@suse.com>
Cc: "Kevin Tian" <kevin.tian@intel.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Julien Grall" <julien@xen.org>, "Wei Liu" <wl@xen.org>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Ian Jackson" <ian.jackson@eu.citrix.com>,
	"George Dunlap" <george.dunlap@citrix.com>,
	"Jun Nakajima" <jun.nakajima@intel.com>,
	xen-devel@lists.xenproject.org,
	"Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>
Subject: Re: [PATCH v8 09/12] xen: add runtime parameter access support to hypfs
Date: Thu, 14 May 2020 17:02:14 +0200	[thread overview]
Message-ID: <95a5644c-e208-57bc-2f47-13581a16b568@suse.com> (raw)
In-Reply-To: <33daeea9-a038-b153-44b5-d9a8a11ae21f@suse.com>

On 14.05.2020 16:56, Jürgen Groß wrote:
> On 14.05.20 14:10, Jan Beulich wrote:
>> On 14.05.2020 13:48, Jürgen Groß wrote:
>>> On 14.05.20 12:20, Jan Beulich wrote:
>>>> On 08.05.2020 17:34, Juergen Gross wrote:
>>>>> --- a/xen/common/grant_table.c
>>>>> +++ b/xen/common/grant_table.c
>>>>> @@ -85,8 +85,43 @@ struct grant_table {
>>>>>        struct grant_table_arch arch;
>>>>>    };
>>>>>    -static int parse_gnttab_limit(const char *param, const char *arg,
>>>>> -                              unsigned int *valp)
>>>>> +unsigned int __read_mostly opt_max_grant_frames = 64;
>>>>> +static unsigned int __read_mostly opt_max_maptrack_frames = 1024;
>>>>> +
>>>>> +#ifdef CONFIG_HYPFS
>>>>> +#define GRANT_CUSTOM_VAL_SZ  12
>>>>> +static char __read_mostly opt_max_grant_frames_val[GRANT_CUSTOM_VAL_SZ];
>>>>> +static char __read_mostly opt_max_maptrack_frames_val[GRANT_CUSTOM_VAL_SZ];
>>>>> +
>>>>> +static void update_gnttab_par(struct param_hypfs *par, unsigned int val,
>>>>> +                              char *parval)
>>>>> +{
>>>>> +    snprintf(parval, GRANT_CUSTOM_VAL_SZ, "%u", val);
>>>>> +    custom_runtime_set_var_sz(par, parval, GRANT_CUSTOM_VAL_SZ);
>>>>> +}
>>>>> +
>>>>> +static void __init gnttab_max_frames_init(struct param_hypfs *par)
>>>>> +{
>>>>> +    update_gnttab_par(par, opt_max_grant_frames, opt_max_grant_frames_val);
>>>>> +}
>>>>> +
>>>>> +static void __init max_maptrack_frames_init(struct param_hypfs *par)
>>>>> +{
>>>>> +    update_gnttab_par(par, opt_max_maptrack_frames,
>>>>> +                      opt_max_maptrack_frames_val);
>>>>> +}
>>>>> +#else
>>>>> +#define opt_max_grant_frames_val    NULL
>>>>> +#define opt_max_maptrack_frames_val NULL
>>>>
>>>> This looks latently dangerous to me (in case new uses of these
>>>> two identifiers appeared), but I guess my alternative suggestion
>>>> will be at best controversial, too:
>>>>
>>>> #define update_gnttab_par(par, val, unused) update_gnttab_par(par, val)
>>>> #define parse_gnttab_limit(par, arg, valp, unused) parse_gnttab_limit(par, arg, valp)
>>>>
>>>> (placed right here)
>>>
>>> Who else would use those identifiers not related to hypfs?
>>
>> I can't see an obvious possible use, but people get creative, i.e.
>> you never know. Passing NULL into a function without it being
>> blindingly obvious that it won't ever get (de)referenced is an at
>> least theoretical risk imo.
> 
> Hmm, what about using a special type for those content variables?
> Something like:
> 
> #ifdef CONFIG_HYPFS
> #define hypfs_string_var            char *
> #else
> #define hypfs_string_var            char
> #define opt_max_grant_frames_val    0
> #define opt_max_maptrack_frames_val 0
> #endif
> 
> And then use that as type for function parameters? This should make
> dereferencing pretty hard.
> 
> Other than that I have no really good idea how to avoid this problem.

IOW (as suspected) you don't like my suggestion? Personally I think
yours, having more #define-s, is at least not better than mine.

Jan


  reply	other threads:[~2020-05-14 15:02 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-08 15:34 [PATCH v8 00/12] Add hypervisor sysfs-like support Juergen Gross
2020-05-08 15:34 ` [PATCH v8 01/12] xen/vmx: let opt_ept_ad always reflect the current setting Juergen Gross
2020-05-08 15:34 ` [PATCH v8 02/12] xen: add a generic way to include binary files as variables Juergen Gross
2020-05-08 15:34 ` [PATCH v8 03/12] docs: add feature document for Xen hypervisor sysfs-like support Juergen Gross
2020-05-08 15:34 ` [PATCH v8 04/12] xen: add basic hypervisor filesystem support Juergen Gross
2020-05-14  7:59   ` Jan Beulich
2020-05-14  9:50     ` Jürgen Groß
2020-05-14 11:58       ` Jan Beulich
2020-05-14 12:12         ` Jürgen Groß
2020-05-15  5:33       ` Jürgen Groß
2020-05-15  9:27         ` Jan Beulich
2020-05-14  9:55   ` Jan Beulich
2020-05-14  9:58     ` Jürgen Groß
2020-05-08 15:34 ` [PATCH v8 05/12] libs: add libxenhypfs Juergen Gross
2020-05-08 15:34 ` [PATCH v8 06/12] tools: add xenfs tool Juergen Gross
2020-05-08 15:34 ` [PATCH v8 07/12] xen: provide version information in hypfs Juergen Gross
2020-05-08 15:34 ` [PATCH v8 08/12] xen: add /buildinfo/config entry to hypervisor filesystem Juergen Gross
2020-05-14  9:32   ` Jan Beulich
2020-05-14  9:52     ` Jürgen Groß
2020-05-08 15:34 ` [PATCH v8 09/12] xen: add runtime parameter access support to hypfs Juergen Gross
2020-05-14 10:20   ` Jan Beulich
2020-05-14 11:48     ` Jürgen Groß
2020-05-14 12:10       ` Jan Beulich
2020-05-14 14:56         ` Jürgen Groß
2020-05-14 15:02           ` Jan Beulich [this message]
2020-05-14 15:43             ` Jürgen Groß
2020-05-08 15:34 ` [PATCH v8 10/12] tools/libxl: use libxenhypfs for setting xen runtime parameters Juergen Gross
2020-05-08 15:34 ` [PATCH v8 11/12] tools/libxc: remove xc_set_parameters() Juergen Gross
2020-05-08 15:34 ` [PATCH v8 12/12] xen: remove XEN_SYSCTL_set_parameter support Juergen Gross
2020-05-14 13:03   ` Jan Beulich
2020-05-14 14:58     ` Jürgen Groß

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=95a5644c-e208-57bc-2f47-13581a16b568@suse.com \
    --to=jbeulich@suse.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jgross@suse.com \
    --cc=julien@xen.org \
    --cc=jun.nakajima@intel.com \
    --cc=kevin.tian@intel.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.