migration: check length directly to make sure the range is aligned
PATCH 1/1 migration: check length directly to make sure the range is aligned
Since the start addr is already checked, to make sure the range is aligned, checking the length is enough.
--- exec.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
exec.c +3 -4
@@ -4067,10 +4067,9 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length)if ((start + length) <= rb->used_length) {bool need_madvise, need_fallocate; -uint8_t *host_endaddr = host_startaddr + length; -if ((uintptr_t )host_endaddr & (rb->page_size -1 )) { -error_report ("ram_block_discard_range: Unaligned end address: %p" , - host_endaddr); +if (length & (rb->page_size -1 )) { +error_report ("ram_block_discard_range: Unaligned length: %lx" , + length); goto err; }
Signature · 1 line
2.17.1
Quoted 13 lines · * Wei Yang ([email protected]) wrote:
Since the start addr is already checked, to make sure the range is aligned, checking the length is enough.
Signed-off-by Wei Yang <[email protected]>--- exec.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)exec.c +0
-0
exec.c int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length) · line 4072
Quoted 10 lines
exec.c +3
-4@@ -4067,10 +4067,9 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length)if ((start + length) <= rb->used_length) {bool need_madvise, need_fallocate; -uint8_t *host_endaddr = host_startaddr + length; -if ((uintptr_t )host_endaddr & (rb->page_size -1 )) { -error_report ("ram_block_discard_range: Unaligned end address: %p" , - host_endaddr); +if (length & (rb->page_size -1 )) { +error_report ("ram_block_discard_range: Unaligned length: %lx" , + length);
Yes, I *think* this is safe, we'll need to watch out for any warnings; David Gibson's balloon fix from February means that the balloon code should now warn in it's case.
rth: Want to pick this up?
Quoted 6 lines
exec.c +0
-0goto err; }Signature · 1 line
2.17.1
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 7 lines · Dr. David Alan Gilbert
exec.c int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length) · line 4072
Quoted 6 lines
exec.c +3
-3-if ((uintptr_t )host_endaddr & (rb->page_size -1 )) { -error_report ("ram_block_discard_range: Unaligned end address: %p" , - host_endaddr); +if (length & (rb->page_size -1 )) { +error_report ("ram_block_discard_range: Unaligned length: %lx" , + length);Yes, I *think* this is safe, we'll need to watch out for any warnings;
Do you mean compiler or QEMU warning? The patch is safe since there's an
if ((uintptr_t)host_startaddr & (rb->page_size - 1)) {
error_report("ram_block_discard_range: Unaligned start address: %p",
host_startaddr);
goto err;
}just before this context.
Paolo
Quoted 10 lines · * Paolo Bonzini ([email protected]) wrote:
Quoted 7 lines · Dr. David Alan Gilbert
exec.c int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length) · line 4072
Quoted 6 lines
exec.c +3
-3-if ((uintptr_t )host_endaddr & (rb->page_size -1 )) { -error_report ("ram_block_discard_range: Unaligned end address: %p" , - host_endaddr); +if (length & (rb->page_size -1 )) { +error_report ("ram_block_discard_range: Unaligned length: %lx" , + length);Yes, I *think* this is safe, we'll need to watch out for any warnings;
Do you mean compiler or QEMU warning?
No, I mean lots of these error reports being printed out in some common case.
Dave
The patch is safe since there's an
Quoted 10 lines
if ((uintptr_t)host_startaddr & (rb->page_size - 1)) { error_report("ram_block_discard_range: Unaligned start address: %p", host_startaddr); goto err; }just before this context.
Paolo
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 10 lines · Dr. David Alan Gilbert
Quoted 9 lines · * Paolo Bonzini ([email protected]) wrote:
Quoted 7 lines · Dr. David Alan Gilbert
exec.c int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length) · line 4072
Quoted 6 lines
exec.c +3
-3-if ((uintptr_t )host_endaddr & (rb->page_size -1 )) { -error_report ("ram_block_discard_range: Unaligned end address: %p" , - host_endaddr); +if (length & (rb->page_size -1 )) { +error_report ("ram_block_discard_range: Unaligned length: %lx" , + length);Yes, I *think* this is safe, we'll need to watch out for any warnings;
Quoted 8 lines
Quoted 1 line
Do you mean compiler or QEMU warning?
No, I mean lots of these error reports being printed out in some common case.
Dave
The patch is safe since there's an
Dave,
Any further comment for this patch? or What should I do next?
Quoted 12 lines
Quoted 10 lines
if ((uintptr_t)host_startaddr & (rb->page_size - 1)) { error_report("ram_block_discard_range: Unaligned start address: %p", host_startaddr); goto err; }just before this context.
Paolo
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Signature · 2 lines
Wei Yang Help you, Help me
Quoted 8 lines · Dr. David Alan Gilbert
Quoted 7 lines · * Paolo Bonzini ([email protected]) wrote:
Quoted 6 lines · Dr. David Alan Gilbert
Quoted 6 lines
exec.c +3
-3-if ((uintptr_t )host_endaddr & (rb->page_size -1 )) { -error_report ("ram_block_discard_range: Unaligned end address: %p" , - host_endaddr); +if (length & (rb->page_size -1 )) { +error_report ("ram_block_discard_range: Unaligned length: %lx" , + length);
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Yes, I *think* this is safe, we'll need to watch out for any warnings;
Do you mean compiler or QEMU warning?
No, I mean lots of these error reports being printed out in some common case.
Hi, Dave
Haven't see you for a period of time :-)
Quoted 15 lines
Dave
The patch is safe since there's an
Quoted 10 lines
if ((uintptr_t)host_startaddr & (rb->page_size - 1)) { error_report("ram_block_discard_range: Unaligned start address: %p", host_startaddr); goto err; }just before this context.
Paolo
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Signature · 2 lines
Wei Yang Help you, Help me
Quoted 13 lines · * Wei Yang ([email protected]) wrote:
Quoted 12 lines · Dr. David Alan Gilbert
Quoted 10 lines · * Paolo Bonzini ([email protected]) wrote:
Quoted 7 lines · Dr. David Alan Gilbert
exec.c int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length) · line 4072
Quoted 6 lines
exec.c +3
-3-if ((uintptr_t )host_endaddr & (rb->page_size -1 )) { -error_report ("ram_block_discard_range: Unaligned end address: %p" , - host_endaddr); +if (length & (rb->page_size -1 )) { +error_report ("ram_block_discard_range: Unaligned length: %lx" , + length);Yes, I *think* this is safe, we'll need to watch out for any warnings;
Do you mean compiler or QEMU warning?
Quoted 7 lines
Quoted 3 lines
No, I mean lots of these error reports being printed out in some common case.
Hi, Dave
Haven't see you for a period of time :-)
I'm here (although been busy with virtiofs) - but this patch is exec.c so I think it needs to be picked by Paolo or rth.
Dave
Quoted 10 lines
Quoted 10 lines
Dave
The patch is safe since there's an
Quoted 7 lines
if ((uintptr_t)host_startaddr & (rb->page_size - 1)) { error_report("ram_block_discard_range: Unaligned start address: %p", host_startaddr); goto err; }
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
just before this context.
Paolo
--
Dr. David Alan Gilbert / [email protected] / Manchester, UKSignature · 2 lines
Wei Yang Help you, Help me
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 18 lines · Dr. David Alan Gilbert
Quoted 17 lines · * Wei Yang ([email protected]) wrote:
Quoted 15 lines · Dr. David Alan Gilbert
Quoted 10 lines · * Paolo Bonzini ([email protected]) wrote:
Quoted 7 lines · Dr. David Alan Gilbert
exec.c int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length) · line 4072
Quoted 6 lines
exec.c +3
-3-if ((uintptr_t )host_endaddr & (rb->page_size -1 )) { -error_report ("ram_block_discard_range: Unaligned end address: %p" , - host_endaddr); +if (length & (rb->page_size -1 )) { +error_report ("ram_block_discard_range: Unaligned length: %lx" , + length);Yes, I *think* this is safe, we'll need to watch out for any warnings;
Do you mean compiler or QEMU warning?
No, I mean lots of these error reports being printed out in some common case.
Quoted 7 lines
Quoted 3 lines
Hi, Dave
Haven't see you for a period of time :-)
I'm here (although been busy with virtiofs) - but this patch is
exec.cso I think it needs to be picked by Paolo or rth.
Thanks Dave
Paolo
Do you feel comfortable with this?
Quoted 23 lines
Dave
Quoted 10 lines
Quoted 10 lines
Dave
The patch is safe since there's an
Quoted 7 lines
if ((uintptr_t)host_startaddr & (rb->page_size - 1)) { error_report("ram_block_discard_range: Unaligned start address: %p", host_startaddr); goto err; }Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
just before this context.
Paolo
--
Dr. David Alan Gilbert / [email protected] / Manchester, UKSignature · 2 lines
Wei Yang Help you, Help me--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Signature · 2 lines
Wei Yang Help you, Help me
Paolo Bonzini
AppliedQuoted 6 lines · Wei Yang
Thanks Dave
Paolo
Do you feel comfortable with this?
Queued now, thanks.
Paolo
Quoted 29 lines · Dr. David Alan Gilbert
Quoted 13 lines · * Wei Yang ([email protected]) wrote:
Since the start addr is already checked, to make sure the range is aligned, checking the length is enough.
Signed-off-by Wei Yang <[email protected]>--- exec.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)exec.c +0
-0exec.c int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length) · line 4072
Quoted 10 lines
exec.c +3
-4@@ -4067,10 +4067,9 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length)if ((start + length) <= rb->used_length) {bool need_madvise, need_fallocate; -uint8_t *host_endaddr = host_startaddr + length; -if ((uintptr_t )host_endaddr & (rb->page_size -1 )) { -error_report ("ram_block_discard_range: Unaligned end address: %p" , - host_endaddr); +if (length & (rb->page_size -1 )) { +error_report ("ram_block_discard_range: Unaligned length: %lx" , + length);Yes, I *think* this is safe, we'll need to watch out for any warnings; David Gibson's balloon fix from February means that the balloon code should now warn in it's case.
Quoted 4 lines
rth: Want to pick this up?
Reviewed-by Dr. David Alan Gilbert <[email protected]>
Hi, David
Do you like this one?
Quoted 8 lines
Quoted 6 lines
exec.c +0
-0goto err; }Signature · 1 line
2.17.1--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Signature · 2 lines
Wei Yang Help you, Help me
Quoted 29 lines · Dr. David Alan Gilbert
Quoted 13 lines · * Wei Yang ([email protected]) wrote:
Since the start addr is already checked, to make sure the range is aligned, checking the length is enough.
Signed-off-by Wei Yang <[email protected]>--- exec.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)exec.c +0
-0exec.c int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length) · line 4072
Quoted 10 lines
exec.c +3
-4@@ -4067,10 +4067,9 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length)if ((start + length) <= rb->used_length) {bool need_madvise, need_fallocate; -uint8_t *host_endaddr = host_startaddr + length; -if ((uintptr_t )host_endaddr & (rb->page_size -1 )) { -error_report ("ram_block_discard_range: Unaligned end address: %p" , - host_endaddr); +if (length & (rb->page_size -1 )) { +error_report ("ram_block_discard_range: Unaligned length: %lx" , + length);Yes, I *think* this is safe, we'll need to watch out for any warnings; David Gibson's balloon fix from February means that the balloon code should now warn in it's case.
Quoted 4 lines
rth: Want to pick this up?
Reviewed-by Dr. David Alan Gilbert <[email protected]>
Any other task I should do for progress?
Quoted 8 lines
Quoted 6 lines
exec.c +0
-0goto err; }Signature · 1 line
2.17.1--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Signature · 2 lines
Wei Yang Help you, Help me