-
-
Notifications
You must be signed in to change notification settings - Fork 52
/
1013-Additional-support-in-ACPI-builder-to-support-SLIC-a.patch
183 lines (171 loc) · 6.7 KB
/
1013-Additional-support-in-ACPI-builder-to-support-SLIC-a.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
From 666298baed7a550e4e5e65097861a4aa06056689 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?=
Date: Wed, 16 Nov 2022 02:20:15 +0100
Subject: [PATCH] Additional support in ACPI builder to support SLIC and OEM
installs.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
In order to use Windows OEM install media, the SLIC table must be passed to a
guest. In addition all the OEM table IDs must match the SLIC or Windows will
think it is invalid and the install ends up unactivated.
NOTE: The DSDT does not get updated. This was the same in the original patch.
Not sure why that is but it is being left that way for now since it works w/o
it.
Ported from qemu-acpi-tables.patch by:
Ross Philipson, [email protected], 05/05/2015
Copied from OpenXT project.
Signed-off-by: Marek Marczykowski-Górecki <[email protected]>
---
tools/libacpi/build.c | 106 +++++++++++++++++++++++++++++++++++++++---
1 file changed, 100 insertions(+), 6 deletions(-)
diff --git a/tools/libacpi/build.c b/tools/libacpi/build.c
index 2f29863db154..55cc81ff18ce 100644
--- a/tools/libacpi/build.c
+++ b/tools/libacpi/build.c
@@ -332,6 +332,66 @@ static int construct_passthrough_tables(struct acpi_ctxt *ctxt,
return nr_added;
}
+static void fixup_headers(struct acpi_header *dest, struct acpi_header *src)
+{
+ char bounce[9];
+
+ if (dest == src)
+ return;
+
+ memset(bounce, 0, 9);
+ memcpy(bounce, dest->oem_id, 6);
+ printf(" Overwriting '%s' with ", bounce);
+ memset(bounce, 0, 9);
+ memcpy(bounce, src->oem_id, 6);
+ printf("'%s' in ", bounce);
+ printf("%c%c%c%c's OEM_ID\n",
+ ((char*)(&dest->signature))[0],
+ ((char*)(&dest->signature))[1],
+ ((char*)(&dest->signature))[2],
+ ((char*)(&dest->signature))[3]);
+
+
+ memcpy(dest->oem_id, src->oem_id, 6);
+
+ memset(bounce, 0, 9);
+ memcpy(bounce, dest->oem_table_id, 8);
+ printf(" Overwriting '%s' with ", bounce);
+ memset(bounce, 0, 9);
+ memcpy(bounce, src->oem_table_id, 8);
+ printf("'%s' in ", bounce);
+ printf("%c%c%c%c's OEM_TABLE_ID\n",
+ ((char*)(&dest->signature))[0],
+ ((char*)(&dest->signature))[1],
+ ((char*)(&dest->signature))[2],
+ ((char*)(&dest->signature))[3]);
+
+
+ memcpy(dest->oem_table_id, src->oem_table_id, 8);
+ set_checksum(dest, offsetof(struct acpi_header, checksum), dest->length);
+}
+
+static int is_slic(struct acpi_header *table)
+{
+ printf(" Table (%c%c%c%c) is ",
+ ((char*)(&table->signature))[0],
+ ((char*)(&table->signature))[1],
+ ((char*)(&table->signature))[2],
+ ((char*)(&table->signature))[3]);
+
+
+ if ( ( ((char*)(&table->signature))[0] == 'S' ) &&
+ ( ((char*)(&table->signature))[1] == 'L' ) &&
+ ( ((char*)(&table->signature))[2] == 'I' ) &&
+ ( ((char*)(&table->signature))[3] == 'C' ) ) {
+ printf("SLIC\n");
+ return 1;
+ }
+
+ printf ("NOT SLIC\n");
+ return 0;
+}
+
static int construct_secondary_tables(struct acpi_ctxt *ctxt,
unsigned long *table_ptrs,
struct acpi_config *config,
@@ -552,6 +612,8 @@ int acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
unsigned long secondary_tables[ACPI_MAX_SECONDARY_TABLES];
int nr_secondaries, i;
unsigned int fadt_size;
+ struct acpi_header *slic_header = NULL;
+ int needs_id_fixup = 0;
acpi_info = (struct acpi_info *)config->infop;
memset(acpi_info, 0, sizeof(*acpi_info));
@@ -671,6 +733,27 @@ int acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
if ( nr_secondaries < 0 )
goto oom;
+ /* We can only have a SLIC if it was passed through. */
+ if ( config->pt.addr ) {
+ /* Check to see if one of the secondary tables is a SLIC. */
+ for (i = 0; i < nr_secondaries; i++) {
+ if (is_slic((struct acpi_header *)secondary_tables[i])) {
+ slic_header = (struct acpi_header *)secondary_tables[i];
+ needs_id_fixup = 1;
+ break;
+ }
+ }
+ }
+
+ /* If we have a SLIC, patch up the other tables to match it. */
+ if (needs_id_fixup) {
+ for (i = 0; i < nr_secondaries; i++) {
+ fixup_headers((struct acpi_header *)secondary_tables[i], slic_header);
+ }
+ fixup_headers(&fadt_10->header, slic_header);
+ fixup_headers(&fadt->header, slic_header);
+ }
+
xsdt = ctxt->mem_ops.alloc(ctxt, sizeof(struct acpi_20_xsdt) +
sizeof(uint64_t) * nr_secondaries,
16);
@@ -680,9 +763,13 @@ int acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
for ( i = 0; secondary_tables[i]; i++ )
xsdt->entry[i+1] = secondary_tables[i];
xsdt->header.length = sizeof(struct acpi_header) + (i+1)*sizeof(uint64_t);
- set_checksum(xsdt,
- offsetof(struct acpi_header, checksum),
- xsdt->header.length);
+ if (needs_id_fixup) {
+ fixup_headers(&xsdt->header, slic_header);
+ } else {
+ set_checksum(xsdt,
+ offsetof(struct acpi_header, checksum),
+ xsdt->header.length);
+ }
rsdt = ctxt->mem_ops.alloc(ctxt, sizeof(struct acpi_20_rsdt) +
sizeof(uint32_t) * nr_secondaries,
@@ -693,9 +780,13 @@ int acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
for ( i = 0; secondary_tables[i]; i++ )
rsdt->entry[i+1] = secondary_tables[i];
rsdt->header.length = sizeof(struct acpi_header) + (i+1)*sizeof(uint32_t);
- set_checksum(rsdt,
- offsetof(struct acpi_header, checksum),
- rsdt->header.length);
+ if (needs_id_fixup) {
+ fixup_headers(&rsdt->header, slic_header);
+ } else {
+ set_checksum(rsdt,
+ offsetof(struct acpi_header, checksum),
+ rsdt->header.length);
+ }
/*
* Fill in low-memory data structures: acpi_info and RSDP.
@@ -705,6 +796,9 @@ int acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
memcpy(rsdp, &Rsdp, sizeof(struct acpi_20_rsdp));
rsdp->rsdt_address = ctxt->mem_ops.v2p(ctxt, rsdt);
rsdp->xsdt_address = ctxt->mem_ops.v2p(ctxt, xsdt);
+ if (needs_id_fixup) {
+ memcpy(rsdp->oem_id, slic_header->oem_id, 6);
+ }
set_checksum(rsdp,
offsetof(struct acpi_10_rsdp, checksum),
sizeof(struct acpi_10_rsdp));
--
2.44.0