lkml.org 
[lkml]   [2019]   [Jul]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/1] x86/boot: clear some fields explicitly
On Thu, 25 Jul 2019, John Hubbard wrote:
> On 7/25/19 3:28 PM, H. Peter Anvin wrote:
> > On 7/25/19 3:03 PM, Thomas Gleixner wrote:
> >> On Thu, 25 Jul 2019, hpa@zytor.com wrote:
> >>> On July 25, 2019 2:48:30 PM PDT, Thomas Gleixner <tglx@linutronix.de> wrote:
> >>>>
> >>>> But seriously I think it's not completely insane what they are doing
> >>>> and the table based approach is definitely more readable and maintainable
> >>>> than the existing stuff.
> >>>
> >>> Doing this table based does seem like a good idea.
> >>
> >> The question is whether we use a 'toclear' table or a 'preserve' table. I'd
> >> argue that the 'preserve' approach is saner.
> >>
> >
> > I agree.
> >
>
> OK, I can polish up something and post it, if you can help me with one more
> quick question: how did you want "to preserve" to work?
>
> a) copy out fields to preserve, memset the area to zero, copy back preserved
> fields? This seems like it would have the same gcc warnings as we have now,
> due to the requirement to memset a range of a struct...

Use the same trick I used for the toclear variant.

#define PRESERVE(m) \
{ \
.start = offsetof(m), \
.len = sizeof(m), \
}

sanitize_boot_params(bp, scratch)
{
char *p1 = bp, *p2 = scratch;

preserve[] = {
PRESERVE(member1),
...
PRESERVE(memberN),
};

for_each_preserve(pr)
memcpy(p2 + pr->start, p1 + pr->start, pr->len)
memcpy(bp, scratch, ...);
}


Thanks,

tglx

\
 
 \ /
  Last update: 2019-07-26 09:45    [W:0.104 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site