Lorenz Brun | 0de1893 | 2021-03-11 00:36:48 +0100 | [diff] [blame] | 1 | Copyright 2020 The Monogon Project Authors. |
| 2 | |
| 3 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | you may not use this file except in compliance with the License. |
| 5 | You may obtain a copy of the License at |
| 6 | |
| 7 | http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | |
| 9 | Unless required by applicable law or agreed to in writing, software |
| 10 | distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | See the License for the specific language governing permissions and |
| 13 | limitations under the License. |
| 14 | |
| 15 | |
Serge Bazanski | fa99799 | 2021-03-23 17:29:42 +0100 | [diff] [blame] | 16 | From 402ac3cc59ef115c41eee0f1dca3b1c4b30d6baa Mon Sep 17 00:00:00 2001 |
Lorenz Brun | 0de1893 | 2021-03-11 00:36:48 +0100 | [diff] [blame] | 17 | From: Lorenz Brun <lorenz@brun.one> |
| 18 | Date: Wed, 10 Mar 2021 17:55:55 +0100 |
Serge Bazanski | fa99799 | 2021-03-23 17:29:42 +0100 | [diff] [blame] | 19 | Subject: [PATCH] Fix QEMU code issues |
| 20 | Company: nexantic GmbH |
Lorenz Brun | 0de1893 | 2021-03-11 00:36:48 +0100 | [diff] [blame] | 21 | |
| 22 | --- |
Serge Bazanski | fa99799 | 2021-03-23 17:29:42 +0100 | [diff] [blame] | 23 | qom/object.c | 2 +- |
| 24 | softmmu/physmem.c | 15 ++++++++++++++- |
| 25 | 2 files changed, 15 insertions(+), 2 deletions(-) |
Lorenz Brun | 0de1893 | 2021-03-11 00:36:48 +0100 | [diff] [blame] | 26 | |
| 27 | diff --git a/qom/object.c b/qom/object.c |
| 28 | index 1065355233..f3aa56cc52 100644 |
| 29 | --- a/qom/object.c |
| 30 | +++ b/qom/object.c |
| 31 | @@ -692,7 +692,7 @@ static void object_finalize(void *data) |
| 32 | |
| 33 | /* Find the minimum alignment guaranteed by the system malloc. */ |
| 34 | #if __STDC_VERSION__ >= 201112L |
| 35 | -typddef max_align_t qemu_max_align_t; |
| 36 | +typedef max_align_t qemu_max_align_t; |
| 37 | #else |
| 38 | typedef union { |
| 39 | long l; |
| 40 | diff --git a/softmmu/physmem.c b/softmmu/physmem.c |
Serge Bazanski | fa99799 | 2021-03-23 17:29:42 +0100 | [diff] [blame] | 41 | index 3027747c03..f5bbdd7e2d 100644 |
Lorenz Brun | 0de1893 | 2021-03-11 00:36:48 +0100 | [diff] [blame] | 42 | --- a/softmmu/physmem.c |
| 43 | +++ b/softmmu/physmem.c |
Serge Bazanski | fa99799 | 2021-03-23 17:29:42 +0100 | [diff] [blame] | 44 | @@ -2675,7 +2675,20 @@ static void invalidate_and_set_dirty(MemoryRegion *mr, hwaddr addr, |
Lorenz Brun | 0de1893 | 2021-03-11 00:36:48 +0100 | [diff] [blame] | 45 | } |
| 46 | if (dirty_log_mask & (1 << DIRTY_MEMORY_CODE)) { |
| 47 | assert(tcg_enabled()); |
| 48 | - tb_invalidate_phys_range(addr, addr + length); |
Serge Bazanski | fa99799 | 2021-03-23 17:29:42 +0100 | [diff] [blame] | 49 | + // Metropolis does not link against TCG (Tiny Code Generator, qemu's |
| 50 | + // software recompilation backend), where tb_invalidate_phys_range is |
| 51 | + // implemented. Because we do not enable TCG at all, this branch should |
| 52 | + // never be taken, and even if it is taken, the assert above should |
| 53 | + // file aborting execution. |
| 54 | + // Ideally, all compilers would use the above data to elide the call to |
| 55 | + // tb_invalidate_phys_range and everything would be fine, but that's |
| 56 | + // unfortunately not the case, at least within Metropolis' build. Thus, |
| 57 | + // in order to prevent the compiler from spuriously linking against a |
| 58 | + // symbol that we do not compile, we comment the call out, and add |
| 59 | + // another assert that will always fire, to truly make sure that this |
| 60 | + // branch never gets taken in practice. |
| 61 | + assert(0); |
Lorenz Brun | 0de1893 | 2021-03-11 00:36:48 +0100 | [diff] [blame] | 62 | + // tb_invalidate_phys_range(addr, addr + length); |
| 63 | dirty_log_mask &= ~(1 << DIRTY_MEMORY_CODE); |
| 64 | } |
| 65 | cpu_physical_memory_set_dirty_range(addr, length, dirty_log_mask); |
| 66 | -- |
Serge Bazanski | fa99799 | 2021-03-23 17:29:42 +0100 | [diff] [blame] | 67 | 2.26.3 |
Lorenz Brun | 0de1893 | 2021-03-11 00:36:48 +0100 | [diff] [blame] | 68 | |