start filling in
[libreriscv.git] / isa_conflict_resolution.mdwn
1 # Resolving ISA conflicts and providing a pain-free RISC-V Standards Upgrade Path
2
3 In a lengthy thread that ironically was full of conflict indicative
4 of the future direction in which RISC-V will go if left unresolved,
5 multiple Custom Extensions were noted to be permitted free rein to
6 introduce global binary-encoding conflict with no means of resolution
7 described or endorsed by the RISC-V Standard: a practice that has known
8 disastrous and irreversible consequences for any architecture that
9 permits such practices (1).
10
11 Much later on in the discussion it was realised that there is also no way
12 within the current RISC-V Specification to transition to improved versions
13 of the standard, regardless of whether the fixes are absolutely critical
14 show-stoppers or whether they are just keeping the standard up-to-date (2).
15
16 With no transition path there is guaranteed to be tension and conflict
17 within the RISC-V Community over whether revisions should be made:
18 should existing legacy designs be prioritised, mutually-exclusively over
19 future designs (and what happens during the transition period is absolute
20 chaos, with the compiler toolchain, software ecosystem and ultimately
21 the end-users bearing the full brunt of the impact). If several
22 overlapping revisions are required that have not yet transitioned out
23 of use (which could take well over two decades to occur) the situation
24 becomes disastrous for the credibility of the entire RISC-V ecosystem.
25
26 It was also pointed out that Compliance is an extremely important factor
27 to take into consideration, and that Custom Extensions (as being optional)
28 effectively fall entirely outside of the Compliance Testing. At this
29 point in the discussion however it was not yet noted the stark problem
30 that the *mandatory* RISC-V Specification also faces, by virtue of there
31 being no transitional way to bring in show-stopping critical alterations.
32
33 To put this into perspective, just taking into account hardware costs
34 alone: with production mask charges for 28nm being around USD $1.5m,
35 engineering development costs and licensing of RTLs for peripherals
36 being of a similar magnitude, no manufacturer is going to back away
37 from selling a "flawed" or "legacy" product (whether it complies with
38 the RISC-V Specification or not) without a bitter fight.
39
40 It was also pointed out that there will be significant software tool
41 maintenance costs for manufacturers, meaning that the probability will
42 be extremely high that they will refuse to shoulder such costs, and
43 publish hopelessly out-of-date unpatched tools. This practice is
44 well-known to result in security flaws going unpatched, with one
45 of many immediate consequences being that product gets discarded into
46 landfill.
47
48 All and any of the issues that were discussed, and all of those that
49 were not, can be avoided by providing a forwards and backwards
50 compatible transition path between the current and future *mandatory*
51 parts of revisions of the RISC-V ISA Standard.
52
53 The rest of the discussion - indicative as it was of the stark mutually
54 exclusive gap being faced by the RISC-V ISA Standard given that it does
55 not cope with the problem - was an effort by two groups in two clear
56 camps: one that wanted things to remain as they are, and another that
57 made efforts to point out that the consequences of not taking action
58 are clearly extreme and irreversible (which, unfortunately, given the
59 severity, some of the first group were unable to believe, despite there
60 being clear historical precedent for the same mistake being made in
61 other architectures).
62
63 However after a significant amount of time, certain clear requirements came
64 out of the discussion:
65
66 * Any proposal must be a minimal change with minimal (or zero) impact
67 * Any proposal should place no restriction on existing or future
68 ISA encoding space
69 * Any proposal should take into account that there are existing implementors
70 of the (yet to be finalised but still "partly frozen") Standard who may
71 resist, for financial investment reasons, efforts to make any change
72 (at all) that could cost them immediate short-term profits.
73
74 Several proposals were put forward (and some are still under discussion)
75
76 * "Do nothing": problem is not severe: no action needed.
77 * "Do nothing": problem is out-of-scope for RISC-V Foundation.
78 * "Do nothing": problem complicates Compliance Testing (and is out of scope)
79 * "MISA": the MISA CSR enables and disables extensions already: use that
80 * "MISA-like": a new CSR which switches in and out new encodings
81 (without destroying state)
82 * "mvendorid/marchid WARL": switching the entire "identity" of a machine
83 * "ioctl-like": a OO proposal based around the linux kernel "ioctl" system.
84
85 Each of these will be discussed below in their own sections.
86
87 # Do nothing (no problem exists)
88
89 TBD (basically not an option).
90
91 There were several solutions offered that fell into this category.
92 A few of them are listed in the introduction; more are listed below,
93 and it was exhaustively (and exhaustingly) established that none of
94 them are workable.
95
96 Initially it was pointed out that Fabless Semiconductor companies could
97 simply license multiple Custom Extensions and a suitable RISC-V core, and
98 modify them accordingly. The Fabless Semi Company would be responsible
99 for paying the NREs on re-developing the test vectors (as the extension
100 licensers would be extremely unlikely to do that without payment), and
101 given that said Companies have an "integration" job to do, it would
102 be reasonable to expect them to have such additional costs as well.
103
104 The costs of this approach were outlined and discussed as being
105 disproportionate and extreme compared to the actual likely cost of
106 licensing the Custom Extensions in the first place. Additionally it
107 was pointed out that not only hardware NREs would be involved but
108 custom software tools (compilers and more) would also be required
109 (and maintained separately, on the basis that upstream would not
110 accept them except under extreme pressure, and then only with
111 prejudice).
112
113 All similar schemes involving customisation of the custom extensions
114 were likewise rejected, but not before the customisation process was
115 mistakenly conflated with tne *normal* integration process of developing
116 a custom processor (Bus Architectures, Cache layouts, peripheral layouts).
117
118 The most compelling hardware-related reason (excluding the severe impact on
119 the software ecosystem) for rejecting the customisation-of-customisation
120 approach was the case where Extensions were using an instruction encoding
121 space (48-bit, 64-bit) *greater* than that which the chosen core could
122 cope with (32-bit, 48-bit).
123
124 Overall, none of the options presented were feasible, and, in addition,
125 even if they were followed through, still would result in the failure
126 of the RISC-V ecosystem due to global conflicting ISA binary-encoding
127 meanings (POWERPC's Altivec / SPE nightmare).
128
129 # Do nothing (out of scope)
130
131 TBD (basically, may not be RV Foundation's "scope", still results in
132 problem, so not an option)
133
134 This was one of the first arguments presented: The RISC-V Foundation
135 considers Custom Extensions to be "out of scope"; that "it's not their
136 problem, therefore there isn't a problem".
137
138 The logical errors in this argument were quickly enumerated: namely
139 that the RISC-V Foundation is not in control of the use-cases, such
140 that binary-encoding is a hundred percent guaranteed to occur, and
141 a hundred percent guaranteed to occur in *commodity* hardware where
142 Debian, Fedora, SUSE and other distros will be hardest hit by the
143 resultant chaos, and that will just be the more "visible" aspect of
144 the underlying problem.
145
146 # Do nothing (Compliance too complex, therefore out of scope)
147
148 TBD (basically, may not be RV Foundation's "scope", still results in
149 problem, so not an option)
150
151 Two interestingly diametrically-opposed equally valid arguments exist here:
152
153 * Whilst Compliance testing of Custom Extensions is definitely legitimately
154 out of scope, Compliance testing of simultaneous legacy (old revisions of
155 ISA Standards) and current (new revisions of ISA Standard) definitely
156 is not. Efforts to reduce *Compliance Testing* complexity is therefore
157 "Compliance Tail Wagging Standard Dog".
158 * Beyond a certain threshold, complexity of Compliance Testing is so
159 burdensome that it risks outright rejection of the entire Standard.
160
161 Meeting these two diametrically-opposed perspectives requires that the
162 solution be very, very simple.
163
164 # MISA
165
166 TBD, basically MISA not suitable
167
168 MISA permits extensions to be disabled by masking out the relevant bit.
169 Hypothetically it could be used to disable one extension, then enable
170 another that happens to use the same binary encoding.
171
172 *However*:
173
174 * MISA Extension disabling is permitted (optionally) to **destroy**
175 the state information. Thus it is totally unsuitable for cases
176 where instructions from different Custom extensions are needed in
177 quick succession.
178 * MISA was only designed to cover Standard Extensions.
179 * There is nothing to prevent multiple Extensions being enabled
180 that wish to simultaneously interpret the same binary encoding.
181
182 Overall, whilst the MISA concept is a step in the right direction it's
183 a hundred percent unsuitable for solving the problem.
184
185 # MISA-like
186
187 TBD, basically same as mvend/march WARL except needs an extra CSR where
188 mv/ma doesn't.
189
190 # mvendorid/marchid WARL
191
192 TBD paraphrase and clarify
193
194 > In an earlier part of the thread someone kindly pointed out that MISA
195 > already switches out entire sets of instructions [which interacts at the
196 > "decode" phase]. However it was noted after a few days of investigating
197 > that particular lead that:
198 >
199 > * MISA Extension disabling is permitted (optionally) to DESTROY the state
200 > information (which means that it *has* to be re-initialised just to be
201 > safe... mistake in the standard, there), and * MISA was only designed
202 > to cover Standard Extensions.
203 >
204 > So the practice of switching extensions in and out - and the resultant
205 > "disablement" and "enablement" at the *instruction decode phase* is
206 > *already* a hard requirement as part of conforming with the present
207 > RISC-V Specification.
208 >
209 > Around the same MISA discussion, someone else also kindly pointed out
210 > that one solution to the heavyweight nature of the switching would
211 > be to deliberately introduce a pipeline stall whilst the switching is
212 > occurring: I can see the sense in that approach, even if I don't know the
213 > full details of what each implementor might choose to do. They may even
214 > choose two, or three, or N pipeline stalls: it really doesn't matter,
215 > as it's an implementors' choice (and problem to solve).
216 >
217 > So yes it's pretty heavy-duty... and also already required.
218 >
219 > For the case where "legacy" variants of the RISC-V Standard are
220 > backwards-forwards-compatibly supported over a 10-20 year period
221 > in Industrial and Military/Goverment-procurement scenarios (so that
222 > the impossible-to-achieve pressure is off to get the spec ABSOLUTELY
223 > correct, RIGHT now), nobody would expect a seriously heavy-duty amount
224 > of instruction-by-instruction switching: it'd be used pretty much once
225 > and only once at boot-up (or once in a Hypervisor Virtual Machine client)
226 > and that's it.
227 >
228 > I can however foresee instances where implementors would actually
229 > genuinely want a bank of operations to be carried out using one extension,
230 > followed immediately by another bank from a (conflicting binary-encoding)
231 > extension, in an inner loop: Software-defined MPEG / MP4 decode to call
232 > DCT block decode Custom Extension followed immediately by Custom Video
233 > Processing Extension followed immediately by Custom DSP Processing
234 > Extension to do YUV-to-RGB conversion for example is something that
235 > is clearly desirable. Solving that one would be entiiirely their
236 > problem... and the RISC-V Specification really really should give them
237 > the space to do that in a clear-cut unambiguous way.
238
239 # ioctl-like
240
241 TBD - [[ioctl]] for full details, summary kept here
242
243 # Discussion and analysis
244
245 TBD
246
247 # Conclusion
248
249 TBD
250
251 # Conversation Exerpts
252
253 The following conversation exerpts are taken from the ISA-dev discussion
254
255 ## (1) Albert Calahan on SPE / Altiven conflict in POWERPC
256
257 > Yes. Well, it should be blocked via legal means. Incompatibility is
258 > a disaster for an architecture.
259 >
260 > The viability of PowerPC was badly damaged when SPE was
261 > introduced. This was a vector instruction set that was incompatible
262 > with the AltiVec instruction set. Software vendors had to choose,
263 > and typically the choice was "neither". Nobody wants to put in the
264 > effort when there is uncertainty and a market fragmented into
265 > small bits.
266 > Note how Intel did not screw up. When SSE was added, MMX remained.
267 > Software vendors could trust that instructions would be supported.
268 > Both MMX and SSE remain today, in all shipping processors. With very
269 > few exceptions, Intel does not ship chips with missing functionality.
270 > There is a unified software ecosystem.
271 >
272 > This goes beyond the instruction set. MMU functionality also matters.
273 > You can add stuff, but then it must be implemented in every future CPU.
274 > You can not take stuff away without harming the architecture.
275
276 ## (2) Luke Kenneth Casson Leighton on Standards backwards-compatibility
277
278 > For the case where "legacy" variants of the RISC-V Standard are
279 > backwards-forwards-compatibly supported over a 10-20 year period in
280 > Industrial and Military/Goverment-procurement scenarios (so that the
281 > impossible-to-achieve pressure is off to get the spec ABSOLUTELY
282 > correct, RIGHT now), nobody would expect a seriously heavy-duty amount
283 > of instruction-by-instruction switching: it'd be used pretty much once
284 > and only once at boot-up (or once in a Hypervisor Virtual Machine
285 > client) and that's it.
286
287 ## (3) Allen Baum on Standards Compliance
288
289 > Putting my compliance chair hat on: One point that was made quite
290 > clear to me is that compliance will only test that an implementation
291 > correctly implements the portions of the spec that are mandatory, and
292 > the portions of the spec that are optional and the implementor claims
293 > it is implementing. It will test nothing in the custom extension space,
294 > and doesn't monitor or care what is in that space.
295