On 2018-08-17 13:30, Ralf Ramsauer wrote:


On 08/17/2018 01:17 PM, Jan Kiszka wrote:
On 2018-08-17 12:55, Ralf Ramsauer wrote:
Hi,

On 08/17/2018 09:19 AM, Jan Kiszka wrote:
Hi Ralf,

this seems to work, despite the comment. Do you remember why we have
that restriction?

diff --git a/hypervisor/include/jailhouse/header.h
b/hypervisor/include/jailhouse/header.h
index 518bc5cb..9dc76f81 100644
--- a/hypervisor/include/jailhouse/header.h
+++ b/hypervisor/include/jailhouse/header.h
@@ -43,7 +43,7 @@ struct jailhouse_virt_console {
       unsigned int tail;
       /* current implementation requires the size of the content to be a
        * power of two */
-    char content[2048];
+    char content[4096 - 2 * sizeof(unsigned int)];

That's been a while… I remember that there have been some arguments, but
it's in deed not obvious by looking at the code…

[grabs out an old review of a previous revision]

Here's the rationale: [1]

Writer side increments the tail pointer without modulo operations
(hv/printk.c:41). If it's not a power of two, it will fail as we get
misaligned once we overflow the unsigned int. AFAICT, on reader side
we're relying on that alignement (main.c:281).

We should improve on documenting that inline.

True.



This issue should become visible, once the tail pointer overflows 32
bit. You could test this situation by offsetting the initialisation of
head/tail.

Right. I was hoping to "cheaply" increase the buffer because it already
overflows during enable on the NUC6CAY. But it's probably easier to
expand it by adding real pages.

Huh? More than 2048 byte log for enabling?

Yes, that fills up quickly. And this is a rather small system. Here is the dump of a 8-core server:

<missed 3262 bytes of console log>
rving 10 interrupt(s) for device 0601 at index 213
Adding PCI device 08:00.0 to cell "RootCell"
Reserving 1 interrupt(s) for device 0800 at index 223
Adding PCI device 09:00.0 to cell "RootCell"
Reserving 4 interrupt(s) for device 0900 at index 224
Adding PCI device ff:0b.0 to cell "RootCell"
Adding PCI device ff:0b.1 to cell "RootCell"
[...]
Adding PCI device ff:1f.0 to cell "RootCell"
Adding PCI device ff:1f.2 to cell "RootCell"
Page pool usage after late setup: mem 334/1482, remap 65806/131072
Activating hypervisor


The downside is that adding a second page wastes again half of its memory.

To get the ratio better, we would have to pass 3 pages :). The problem is that we have two additional values that always need one page at least (when using >=1 page for the content). Or we change the wrap-around logic consistently to modulo. But that is, well, error-prone.

Jan

--
Siemens AG, Corporate Technology, CT RDA IOT 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