On 2017-01-16 17:07, Ralf Ramsauer wrote:
> If the console is enabled. Don't write messages to the console page if
> it is disabled. Otherwise we would leak information if we disable the
> hypervisor.
> 
> Signed-off-by: Ralf Ramsauer <[email protected]>
> ---
>  hypervisor/printk.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/hypervisor/printk.c b/hypervisor/printk.c
> index aad6dadc..7b9cfd2a 100644
> --- a/hypervisor/printk.c
> +++ b/hypervisor/printk.c
> @@ -23,7 +23,24 @@ struct jailhouse_console console 
> __attribute__((section(".console")));
>  
>  static DEFINE_SPINLOCK(printk_lock);
>  
> -#define console_write(msg)   arch_dbg_write(msg)
> +static void console_write(const char *msg)
> +{
> +     arch_dbg_write(msg);
> +
> +     if (!console_print)
> +             return;
> +
> +     console.lock = true;
> +     memory_barrier();
> +     while (*msg) {
> +             console.content[console.tail % sizeof(console.content)] =
> +                     *msg++;
> +             console.tail++;
> +     }
> +     console.lock = false;
> +     memory_barrier();

Barrier has to come before the lock update.

You should leave comments why we need the barriers: The first one, to
ensure the lock is visible prior to starting any content or tail update.
The second, to make sure that those updates are committed before unlocking.

> +}
> +
>  #include "printk-core.c"
>  
>  static void dbg_write_stub(const char *msg)
> 

Jan

-- 
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to