(no commit message)
[libreriscv.git] / isa_conflict_resolution.mdwn
1 # Resolving ISA conflicts and providing a pain-free RISC-V Standards Upgrade Path
2
3 **Note: out-of-date as of review 31apr2018, requires updating to reflect
4 "mvendorid-marchid-isamux" concept.** Recent discussion 10jun2019
5 <https://groups.google.com/a/groups.riscv.org/d/msg/isa-dev/x-uFZDXiOxY/_ISBs1enCgAJ>.
6 Now updated with its own spec [[isamux_isans]].
7
8 ## Executive Summary
9
10 A non-invasive backwards-compatible change to make mvendorid and marchid
11 being read-only to be a formal declaration of an architecture having no
12 Custom Extensions, and being permitted to be WARL in order to support
13 multiple simultaneous architectures on the same processor (or per hart
14 or harts) permits not only backwards and forwards compatibility with
15 existing implementations of the RISC-V Standard, not only permits seamless
16 transitions to future versions of the RISC-V Standard (something that is
17 not possible at the moment), but fixes the problem of clashes in Custom
18 Extension opcodes on a global worldwide permanent and ongoing basis.
19
20 Summary of impact and benefits:
21
22 * Implementation impact for existing implementations (even though
23 the Standard is not finalised) is zero.
24 * Impact for future implementations compliant with (only one) version of the
25 RISC-V Standard is zero.
26 * Benefits for implementations complying with (one or more) versions
27 of the RISC-V Standard is: increased customer acceptance due to
28 a smooth upgrade path at the customer's pace and initiative vis-a-vis
29 legacy proprietary software.
30 * Benefits for implementations deploying multiple Custom Extensions
31 are a massive reduction in NREs and the hugely reduced ongoing software
32 toolchain maintenance costs plus the benefit of having security updates
33 from upstream software sources due to
34 *globally unique identifying information* resulting in zero binary
35 encoding conflicts in the toolchains and resultant binaries
36 *even for Custom Extensions*.
37
38 ## Introduction
39
40 In a lengthy thread that ironically was full of conflict indicative
41 of the future direction in which RISC-V will go if left unresolved,
42 multiple Custom Extensions were noted to be permitted free rein to
43 introduce global binary-encoding conflict with no means of resolution
44 described or endorsed by the RISC-V Standard: a practice that has known
45 disastrous and irreversible consequences for any architecture that
46 permits such practices (1).
47
48 Much later on in the discussion it was realised that there is also no way
49 within the current RISC-V Specification to transition to improved versions
50 of the standard, regardless of whether the fixes are absolutely critical
51 show-stoppers or whether they are just keeping the standard up-to-date (2).
52
53 With no transition path there is guaranteed to be tension and conflict
54 within the RISC-V Community over whether revisions should be made:
55 should existing legacy designs be prioritised, mutually-exclusively over
56 future designs (and what happens during the transition period is absolute
57 chaos, with the compiler toolchain, software ecosystem and ultimately
58 the end-users bearing the full brunt of the impact). If several
59 overlapping revisions are required that have not yet transitioned out
60 of use (which could take well over two decades to occur) the situation
61 becomes disastrous for the credibility of the entire RISC-V ecosystem.
62
63 It was also pointed out that Compliance is an extremely important factor
64 to take into consideration, and that Custom Extensions (as being optional)
65 effectively and quite reasonably fall entirely outside of the scope of
66 Compliance Testing. At this point in the discussion however it was not
67 yet noted the stark problem that the *mandatory* RISC-V Specification
68 also faces, by virtue of there being no transitional way to bring in
69 show-stopping critical alterations.
70
71 To put this into perspective, just taking into account hardware costs
72 alone: with production mask charges for 28nm being around USD $1.5m,
73 engineering development costs and licensing of RTLs for peripherals
74 being of a similar magnitude, no manufacturer is going to back away
75 from selling a "flawed" or "legacy" product (whether it complies with
76 the RISC-V Specification or not) without a bitter fight.
77
78 It was also pointed out that there will be significant software tool
79 maintenance costs for manufacturers, meaning that the probability will
80 be extremely high that they will refuse to shoulder such costs, and
81 will publish and continue to publish (and use) hopelessly out-of-date
82 unpatched tools. This practice is well-known to result in security
83 flaws going unpatched, with one of many immediate undesirable consequences
84 being that product in extremely large volume gets discarded into landfill.
85
86 **All and any of the issues that were discussed, and all of those that
87 were not, can be avoided by providing a hardware-level runtime-enabled
88 forwards and backwards compatible transition path between *all* parts
89 (mandatory or not) of current and future revisions of the RISC-V ISA
90 Standard.**
91
92 The rest of the discussion - indicative as it was of the stark mutually
93 exclusive gap being faced by the RISC-V ISA Standard given that it does
94 not cope with the problem - was an effort by two groups in two clear
95 camps: one that wanted things to remain as they are, and another that
96 made efforts to point out that the consequences of not taking action
97 are clearly extreme and irreversible (which, unfortunately, given the
98 severity, some of the first group were unable to believe, despite there
99 being clear historical precedent for the exact same mistake being made in
100 other architectures, and the consequences on the same being absolutely
101 clear).
102
103 However after a significant amount of time, certain clear requirements came
104 out of the discussion:
105
106 * Any proposal must be a minimal change with minimal (or zero) impact
107 * Any proposal should place no restriction on existing or future
108 ISA encoding space
109 * Any proposal should take into account that there are existing implementors
110 of the (yet to be finalised but still "partly frozen") Standard who may
111 resist, for financial investment reasons, efforts to make any change
112 (at all) that could cost them immediate short-term profits.
113
114 Several proposals were put forward (and some are still under discussion)
115
116 * "Do nothing": problem is not severe: no action needed.
117 * "Do nothing": problem is out-of-scope for RISC-V Foundation.
118 * "Do nothing": problem complicates Compliance Testing (and is out of scope)
119 * "MISA": the MISA CSR enables and disables extensions already: use that
120 * "MISA-like": a new CSR which switches in and out new encodings
121 (without destroying state)
122 * "mvendorid/marchid WARL": switching the entire "identity" of a machine
123 * "ioctl-like": a OO proposal based around the linux kernel "ioctl" system.
124
125 Each of these will be discussed below in their own sections.
126
127 # Do nothing (no problem exists)
128
129 (Summary: not an option)
130
131 There were several solutions offered that fell into this category.
132 A few of them are listed in the introduction; more are listed below,
133 and it was exhaustively (and exhaustingly) established that none of
134 them are workable.
135
136 Initially it was pointed out that Fabless Semiconductor companies could
137 simply license multiple Custom Extensions and a suitable RISC-V core, and
138 modify them accordingly. The Fabless Semi Company would be responsible
139 for paying the NREs on re-developing the test vectors (as the extension
140 licensers would be extremely unlikely to do that without payment), and
141 given that said Companies have an "integration" job to do, it would
142 be reasonable to expect them to have such additional costs as well.
143
144 The costs of this approach were outlined and discussed as being
145 disproportionate and extreme compared to the actual likely cost of
146 licensing the Custom Extensions in the first place. Additionally it
147 was pointed out that not only hardware NREs would be involved but
148 custom software tools (compilers and more) would also be required
149 (and maintained separately, on the basis that upstream would not
150 accept them except under extreme pressure, and then only with
151 prejudice).
152
153 All similar schemes involving customisation of the custom extensions
154 were likewise rejected, but not before the customisation process was
155 mistakenly conflated with tne *normal* integration process of developing
156 a custom processor (Bus Architectures, Cache layouts, peripheral layouts).
157
158 The most compelling hardware-related reason (excluding the severe impact on
159 the software ecosystem) for rejecting the customisation-of-customisation
160 approach was the case where Extensions were using an instruction encoding
161 space (48-bit, 64-bit) *greater* than that which the chosen core could
162 cope with (32-bit, 48-bit).
163
164 Overall, none of the options presented were feasible, and, in addition,
165 with no clear leadership from the RISC-V Foundation on how to avoid
166 global world-wide encoding conflict, even if they were followed through,
167 still would result in the failure of the RISC-V ecosystem due to
168 irreversible global conflicting ISA binary-encoding meanings (POWERPC's
169 Altivec / SPE nightmare).
170
171 This in addition to the case where the RISC-V Foundation wishes to
172 fix a critical show-stopping update to the Standard, post-release,
173 where billions of dollars have been spent on deploying RISC-V in the
174 field.
175
176 # Do nothing (out of scope)
177
178 (Summary: may not be RV Foundation's "scope", still results in
179 problem, so not an option)
180
181 This was one of the first arguments presented: The RISC-V Foundation
182 considers Custom Extensions to be "out of scope"; that "it's not their
183 problem, therefore there isn't a problem".
184
185 The logical errors in this argument were quickly enumerated: namely that
186 the RISC-V Foundation is not in control of the uses to which RISC-V is
187 put, such that public global conflicts in binary-encoding are a hundred
188 percent guaranteed to occur (*outside* of the control and remit of the
189 RISC-V Foundation), and a hundred percent guaranteed to occur in
190 *commodity* hardware where Debian, Fedora, SUSE and other distros will
191 be hardest hit by the resultant chaos, and that will just be the more
192 "visible" aspect of the underlying problem.
193
194 # Do nothing (Compliance too complex, therefore out of scope)
195
196 (Summary: may not be RV Foundation's "scope", still results in
197 problem, so not an option)
198
199 The summary here was that Compliance testing of Custom Extensions is
200 not just out-of-scope, but even if it was taken into account that
201 binary-encoding meanings could change, it would still be out-of-scope.
202
203 However at the time that this argument was made, it had not yet been
204 appreciated fully the impact that revisions to the Standard would have,
205 when billions of dollars worth of (older, legacy) RISC-V hardware had
206 already been deployed.
207
208 Two interestingly diametrically-opposed equally valid arguments exist here:
209
210 * Whilst Compliance testing of Custom Extensions is definitely legitimately
211 out of scope, Compliance testing of simultaneous legacy (old revisions of
212 ISA Standards) and current (new revisions of ISA Standard) definitely
213 is not. Efforts to reduce *Compliance Testing* complexity is therefore
214 "Compliance Tail Wagging Standard Dog".
215 * Beyond a certain threshold, complexity of Compliance Testing is so
216 burdensome that it risks outright rejection of the entire Standard.
217
218 Meeting these two diametrically-opposed perspectives requires that the
219 solution be very, very simple.
220
221 # MISA
222
223 (Summary: MISA not suitable, leads to better idea)
224
225 MISA permits extensions to be disabled by masking out the relevant bit.
226 Hypothetically it could be used to disable one extension, then enable
227 another that happens to use the same binary encoding.
228
229 *However*:
230
231 * MISA Extension disabling is permitted (optionally) to **destroy**
232 the state information. Thus it is totally unsuitable for cases
233 where instructions from different Custom extensions are needed in
234 quick succession.
235 * MISA was only designed to cover Standard Extensions.
236 * There is nothing to prevent multiple Extensions being enabled
237 that wish to simultaneously interpret the same binary encoding.
238 * There is nothing in the MISA specification which permits
239 *future* versions (bug-fixes) of the RISC-V ISA to be "switched in".
240
241 Overall, whilst the MISA concept is a step in the right direction it's
242 a hundred percent unsuitable for solving the problem.
243
244 # MISA-like
245
246 (Summary: basically same as mvend/march WARL except needs an extra CSR where
247 mv/ma doesn't. Along right lines, doesn't meet full requirements)
248
249 Out of the MISA discussion came a "MISA-like" proposal, which would
250 take into account the flaws pointed out by trying to use "MISA":
251
252 * The MISA-like CSR's meaning would be identified by compilers using the
253 mvendor-id/march-id tuple as a compiler target
254 * Each custom-defined bit of the MISA-like CSR would (mutually-exclusively)
255 redirect binary encoding(s) to specific encodings
256 * No Extension would *actually* be disabled: its internal state would
257 be left on (permanently) so that switching of ISA decoding
258 could be done inside inner loops without adverse impact on
259 performance.
260
261 Whilst it was the first "workable" solution it was also noted that the
262 scheme is invasive: it requires an entirely new CSR to be added
263 to the privileged spec (thus making existing implementations redundant).
264 This does not fulfil the "minimum impact" requirement.
265
266 Also interesting around the same time an additional discussion was
267 raised that covered the *compiler* side of the same equation. This
268 revolved around using mvendorid-marchid tuples at the compiler level,
269 to be put into assembly output (by gcc), preserving the required
270 *globally* unique identifying information for binutils to successfully
271 turn the custom instruction into an actual binary-encoding (plus
272 binary-encoding of the context-switching information). (**TBD, Jacob,
273 separate page? review this para?**)
274
275 # mvendorid/marchid WARL <a name="mvendor_marchid_warl"></a>
276
277 (Summary: the only idea that meets the full requirements. Needs
278 toolchain backup, but only when the first chip is released)
279
280 This proposal has full details at the following page:
281 [[mvendor_march_warl]]
282
283 Coming out of the software-related proposal by Jacob Bachmeyer, which
284 hinged on the idea of a globally-maintained gcc / binutils database
285 that kept and coordinated architectural encodings (curated by the Free
286 Software Foundation), was to quite simply make the mvendorid and marchid
287 CSRs have WARL (writeable) characteristics. Read-only is taken to
288 mean a declaration of "Having no Custom Extensions" (a zero-impact
289 change).
290
291 By making mvendorid-marchid tuples WARL the instruction decode phase
292 may re-route mutually-exclusively to different engines, thus providing
293 a controlled means and method of supporting multiple (future, past and
294 present) versions of the **Base** ISA, Custom Extensions and even
295 completely foreign ISAs in the same processor.
296
297 This incredibly simple non-invasive idea has some unique and distinct
298 advantages over other proposals:
299
300 * Existing designs - even though the specification is not finalised
301 (but has "frozen" aspects) - would be completely unaffected: the
302 change is to the "wording" of the specification to "retrospectively"
303 fit reality.
304 * Unlike with the MISA idea this is *purely* at the "decode" phase:
305 no internal Extension state information is permitted to be disabled,
306 altered or destroyed as a direct result of writing to the
307 mvendor/march-id CSRs.
308 * Compliance Testing may be carried out with a different vendorid/marchid
309 tuple set prior to a test, allowing a vendor to claim *Certified*
310 compatibility with *both* one (or more) legacy variants of the RISC-V
311 Specification *and* with a present one.
312 * With sufficient care taken in the implementation an implementor
313 may have multiple interpretations of the same binary encoding within
314 an inner loop, with a single instruction (to the WARL register)
315 changing the meaning.
316
317 **This is the only one of the proposals that meet the full requirements**
318
319 # Overloadable opcodes <a name="overloadable opcodes"></a>
320
321 See [[overloadable opcodes]] for full details, including a description in terms of C functions.
322
323 NOTE: under discussion.
324
325 ==RB 2018-5-1 dropped IOCTL proposal for the much simpler overloadable opcodes proposal==
326
327 The overloadable opcode (or xext) proposal allows a non standard extension to use a documented 20 + 3 bit (or 52 + 3 bit on RV64) UUID identifier for an instruction for _software_ to use. At runtime, a cpu translates the UUID to a small implementation defined 12 + 3 bit bit identifier for _hardware_ to use. It also defines a fallback mechanism for the UUID's of instructions the cpu does not recognise.
328
329 The overloadable opcodes proposal defines 8 standardised R-type instructions xcmd0, xcmd1, ...xcmd7 preferably in the brownfield opcode space.
330 Each xcmd takes in rs1 a 12 bit "logical unit" (lun) identifying a device on the cpu that implements some "extension interface" (xintf) together with some additional data. An xintf is a set of up to 8 commands with 2 input and 1 output port (i.e. like an R-type instruction), together with a description of the semantics of the commands. Calling e.g. xcmd3 routes its two inputs and one output ports to command 3 on the device determined by the lun bits in rs1. Thus, the 8 standard xcmd instructions are standard-designated overloadable opcodes, with the non standard semantics of the opcode determined by the lun.
331
332 Portable software, does not use luns directly. Instead, it goes through a level of indirection using a further instruction xext that translates a 20 bit globally unique identifier UUID of an xintf, to the lun of a device on the cpu that implements that xintf. The cpu can do this, because it knows (at manufacturing or boot time) which devices it has, and which xintfs they provide. This includes devices that would be described as non standard extension of the cpu if the designers had used custom opcodes instead of xintf as an interface. If the UUID of the xintf is not recognised at the current privilege level, the xext instruction returns the special lun = 0, causing any xcmd to trap. Minor variations of this scheme (requiring two more instructions) cause xcmd instructions to fallback to always return 0 or -1 instead of trapping.
333
334 The 20 bit provided by the UUID of the xintf is much more room than provided by the 2 custom 32 bit, or even 4 custom 64/48 bit opcode spaces. Thus the overloadable opcodes proposal avoids most of the need to put a claim on opcode space and the associated collisions when combining independent extensions. In this respect it is similar to POSIX ioctls, which obviate the need for defining new syscalls to control new and nonstandard hardware.
335
336 Remark1: the main difference with a previous "ioctl like proposal" is that UUID translation is stateless and does not use resources. The xext instruction _neither_ initialises a device _nor_ builds global state identified by a cookie. If a device needs initialisation it can do this using xcmds as init and deinit instructions. Likewise, it can hand out cookies (which can include the lun) as a return value .
337
338 Remark2: Implementing devices can respond to an (essentially) arbitrary number of xintfs. Hence an implementing device can respond to an arbitrary number of commands. Organising related commands in xintfs, helps avoid UUID space pollution, and allows to amortise the (small) cost of UUID to lun translation if related commands are used in combination.
339
340 ==RB not sure if this is still correct and relevant==
341
342 The proposal is functionally similar to that of the mvendor/march-id
343 except the non standard extension is explicit and restricted to a small set of well defined individual opcodes.
344 Hence several extensions can be mixed and there is no state to be tracked over context switches.
345 As such it could hypothetically be proposed as an independent Standard Extension.
346
347 Despite the proposal (which is still undergoing clarification)
348 being worthwhile in its own right, and standing on its own merits and
349 thus definitely worthwhile pursuing, it is non-trivial and more
350 invasive than the mvendor/march-id WARL concept.
351
352 ==RB==
353
354 # Dynamic runtime hardware-adjustable custom opcode encodings <a name="dynamic_opcodes"></a>
355
356 Perhaps this is a misunderstanding, that what is being advocated
357 below (see link for full context):
358
359 > The best that can be done is to allow each custom extension to have
360 > its opcodes easily re positioned depending on what other custom extensions
361 > the user wants available in the same program (without mode switches).
362
363 It was suggested to use markers in the object files as a way to
364 identify opcodes that can be "re-encoded". Contrast this with Jacob
365 Bachmeyer's original idea where the *assembly code* (only) contains
366 such markers (on a global world-wide unique basis, using mvendorid-marchid-isamux
367 tuples to do so).
368
369 <https://groups.google.com/a/groups.riscv.org/d/msg/isa-dev/Jnon96tVQD0/XuHWvduvDQAJ>
370
371 There are two possible interpretations of this:
372
373 * (1) the Hardware RTL is reconfigureable (parameterisable) to allow
374 easy selection of *static* moving (adjustment) of which opcodes a
375 particular instruction uses. This runs into the same difficulties
376 as outlined in other areas of this document.
377 * (2) the Hardware RTL contains DYNAMIC and RUN-TIME CONFIGUREABLE
378 opcodes (presumably using additional CSRs to move meanings)
379
380 This would help any implementation to adjust to whatever future (official)
381 uses a particular encoding was selected. It would be particularly useful
382 if an implementation used certain brownfield encodings.
383
384 The only downsides are:
385
386 * (1) Compiler support for dynamic opcode reconfiguration would be...
387 complex.
388 * (2) The instruction decode phase is also made more complex, now
389 involving reconfigureable lookup tables. Whilst major opcodes
390 can be easily redirected, brownfield encodings are more involved.
391
392 Compared to a stark choice of having to move (exclusively) to 48-bit
393 or 64-bit encodings, dynamic runtime opcode reconfiguration is
394 comparatively much more palatable.
395
396 In effect, it is a much more advanced version of ISAMUX/NS
397 (see [[isamux_isans]]).
398
399 # Comments, Discussion and analysis
400
401 TBD: placeholder as of 26apr2018
402
403 ## new (old) m-a-i tuple idea
404
405 > actually that's a good point: where the user decides that they want
406 > to boot one and only one tuple (for the entire OS), forcing a HARDWARE
407 > level default m-a-i tuple at them actually prevents and prohibits them
408 > from doing that, Jacob.
409 >
410 > so we have apps on one RV-Base ISA and apps on an INCOMPATIBLE (future)
411 > variant of RV-Base ISA.  with the approach that i was advocating (S-mode
412 > does NOT switch automatically), there are totally separate mtvec /
413 > stvec / bstvec traps.
414 >
415 > would it be reasonable to assume the following:
416 >
417 > (a) RV-Base ISA, particularly code-execution in the critical S-mode
418 > trap-handling, is *EXTREMELY* unlikely to ever be changed, even thinking
419 > 30 years into the future ?
420 >
421 > (b) if the current M-mode (user app level) context is "RV Base ISA 1"
422 > then i would hazard a guess that S-mode is prettty much going to drop
423 > down into *exactly* the same mode / context, the majority of the time
424 >
425 > thus the hypothesis is that not only is it the common code-path to *not*
426 > switch the ISA in the S-mode trap but that the instructions used are
427 > extremely unlikely to be changed between "RV Base Revisions".
428 >
429 > foreign isa hardware-level execution
430 > ------------------------
431 >
432 > this is the one i've not really thought through so much, other than it
433 > would clearly be disadvantageous for S-mode to be arbitrarily restricted
434 > to running RV-Base code (of any variant).  a case could be made that by the
435 > time the m-a-i tuple is switched to the foreign isa it's "all bets off",
436 > foreign arch is "on its own", including having to devise a means and
437 > method to switch back (equivalent in its ISA of m-a-i switching).
438 >
439 > conclusion / idea
440 > --------------------
441 >
442 > the multi-base "user wants to run one and only one tuple" is the key
443 > case, here, that is a show-stopper to the idea of hard-wiring the default
444 > S-mode m-a-i.
445 >
446 > now, if instead we were to say, "ok so there should be a default S-mode
447 > m-a-i tuple" and it was permitted to SET (choose) that tuple, *that*
448 > would solve that problem.  it could even be set to the foreign isa. 
449 > which would be hilarious.
450
451 jacob's idea: one hart, one configuration:
452
453 >>>  (a) RV-Base ISA, particularly code-execution in the critical S-mode
454 >>> trap-handling, is *EXTREMELY* unlikely to ever be changed, even
455 >>> thinking 30 years into the future ?
456 >>
457 >> Oddly enough, due to the minimalism of RISC-V, I believe that this is
458 >> actually quite likely.  :-)
459 >>
460 >>>  thus the hypothesis is that not only is it the common code-path to
461 >>> *not* switch the ISA in the S-mode trap but that the instructions used
462 >>> are extremely unlikely to be changed between "RV Base Revisions".
463 >>>
464 >> Correct.  I argue that S-mode should *not* be able to switch the selected
465 >> ISA on multi-arch processors. 
466 >
467 > that would produce an artificial limitation which would prevent
468 > and prohibit implementors from making a single-core (single-hart)
469 > multi-configuration processor.
470
471
472
473 # Summary and Conclusion
474
475 In the early sections (those in the category "no action") it was established
476 in each case that the problem is not solved. Avoidance of responsibility,
477 or conflation of "not our problem" with "no problem" does not make "problem"
478 go away. Even "making it the Fabless Semiconductor's design problem" resulted
479 in a chip being *more costly to engineer as hardware **and** more costly
480 from a software-support perspective to maintain*... without actually
481 fixing the problem.
482
483 The first idea considered which could fix the problem was to just use
484 the pre-existing MISA CSR, however this was determined not to have
485 the right coverage (Standard Extensions only), and also crucially it
486 destroyed state. Whilst unworkable it did lead to the first "workable"
487 solution, "MISA-like".
488
489 The "MISA-like" proposal, whilst meeting most of the requirements, led to
490 a better idea: "mvendor/march-id WARL", which, in combination with an offshoot
491 idea related to gcc and binutils, is the only proposal that fully meets the
492 requirements.
493
494 The "ioctl-like" idea *also* solves the problem, but, unlike the WARL idea
495 does not meet the full requirements to be "non-invasive" and "backwards
496 compatible" with pre-existing (pre-Standards-finalised) implementations.
497 It does however stand on its own merit as a way to extend the extremely
498 small Custom Extension opcode space, even if it itself implemented *as*
499 a Custom Extension into which *other* Custom Extensions are subsequently
500 shoe-horned. This approach has the advantage that it requires no "approval"
501 from the RISC-V Foundation... but without the RISC-V Standard "approval"
502 guaranteeing no binary-encoding conflicts, still does not actually solve the
503 problem (if deployed as a Custom Extension for extending Custom Extensions).
504
505 Overall the mvendor/march-id WARL idea meets the three requirements,
506 and is the only idea that meets the three requirements:
507
508 * **Any proposal must be a minimal change with minimal (or zero) impact**
509 (met through being purely a single backwards-compatible change to the
510 wording of the specification: mvendor/march-id changes from read-only
511 to WARL)
512 * **Any proposal should place no restriction on existing or future
513 ISA encoding space**
514 (met because it is just a change to one pre-existing CSR, as opposed
515 to requiring additional CSRs or requiring extra opcodes or changes
516 to existing opcodes)
517 * **Any proposal should take into account that there are existing implementors
518 of the (yet to be finalised but still "partly frozen") Standard who may
519 resist, for financial investment reasons, efforts to make any change
520 (at all) that could cost them immediate short-term profits.**
521 (met because existing implementations, with the exception of those
522 that have Custom Extensions, come under the "vendor/arch-id read only
523 is a formal declaration of an implementation having no Custom Extensions"
524 fall-back category)
525
526 So to summarise:
527
528 * The consequences of not tackling this are severe: the RISC-V Foundation
529 cannot take a back seat. If it does, clear historical precedent shows
530 100% what the outcome will be (1).
531 * Making the mvendorid and marchid CSRs WARL solves the problem in a
532 minimal to zero-disruptive backwards-compatible fashion that provides
533 indefinite transparent *forwards*-compatibility.
534 * The retro-fitting cost onto existing implementations (even though the
535 specification has not been finalised) is zero to negligeable
536 (only changes to words in the specification required at this time:
537 no vendor need discard existing designs, either being designed,
538 taped out, or actually in production).
539 * The benefits are clear (pain-free transition path for vendors to safely
540 upgrade over time; no fights over Custom opcode space; no hassle for
541 software toolchain; no hassle for GNU/Linux Distros)
542 * The implementation details are clear (and problem-free except for
543 vendors who insist on deploying dozens of conflicting Custom Extensions:
544 an extreme unlikely outlier).
545 * Compliance Testing is straightforward and allows vendors to seek and
546 obtain *multiple* Compliance Certificates with past, present and future
547 variants of the RISC-V Standard (in the exact same processor,
548 simultaneously), in order to support end-customer legacy scenarios and
549 provide the same with a way to avoid "impossible-to-make" decisions that
550 throw out ultra-costly multi-decade-investment in proprietary legacy
551 software at the same as the (legacy) hardware.
552
553 -------
554
555 # Conversation Exerpts
556
557 The following conversation exerpts are taken from the ISA-dev discussion
558
559 ## (1) Albert Calahan on SPE / Altiven conflict in POWERPC
560
561 > Yes. Well, it should be blocked via legal means. Incompatibility is
562 > a disaster for an architecture.
563 >
564 > The viability of PowerPC was badly damaged when SPE was
565 > introduced. This was a vector instruction set that was incompatible
566 > with the AltiVec instruction set. Software vendors had to choose,
567 > and typically the choice was "neither". Nobody wants to put in the
568 > effort when there is uncertainty and a market fragmented into
569 > small bits.
570 >
571 > Note how Intel did not screw up. When SSE was added, MMX remained.
572 > Software vendors could trust that instructions would be supported.
573 > Both MMX and SSE remain today, in all shipping processors. With very
574 > few exceptions, Intel does not ship chips with missing functionality.
575 > There is a unified software ecosystem.
576 >
577 > This goes beyond the instruction set. MMU functionality also matters.
578 > You can add stuff, but then it must be implemented in every future CPU.
579 > You can not take stuff away without harming the architecture.
580
581 ## (2) Luke Kenneth Casson Leighton on Standards backwards-compatibility
582
583 > For the case where "legacy" variants of the RISC-V Standard are
584 > backwards-forwards-compatibly supported over a 10-20 year period in
585 > Industrial and Military/Goverment-procurement scenarios (so that the
586 > impossible-to-achieve pressure is off to get the spec ABSOLUTELY
587 > correct, RIGHT now), nobody would expect a seriously heavy-duty amount
588 > of instruction-by-instruction switching: it'd be used pretty much once
589 > and only once at boot-up (or once in a Hypervisor Virtual Machine
590 > client) and that's it.
591
592 ## (3) Allen Baum on Standards Compliance
593
594 > Putting my compliance chair hat on: One point that was made quite
595 > clear to me is that compliance will only test that an implementation
596 > correctly implements the portions of the spec that are mandatory, and
597 > the portions of the spec that are optional and the implementor claims
598 > it is implementing. It will test nothing in the custom extension space,
599 > and doesn't monitor or care what is in that space.
600
601 ## (4) Jacob Bachmeyer on explaining disambiguation of opcode space
602
603 > ...have different harts with different sets of encodings.)  Adding a "select"
604 > CSR as has been proposed does not escape this fundamental truth that
605 > instruction decode must be unambiguous, it merely expands every opcode with
606 > extra bits from a "select" CSR.
607
608 ## (5) Krste Asanovic on clarification of use of opcode space
609
610 > A CPU is even free to reuse some standard extension encoding space for
611 > non-standard extensions provided it does not claim to implement that
612 > standard extension.
613
614 ## (6) Clarification of difference between assembler and encodings
615
616 > > The extensible assembler database I proposed assumes that each processor
617 > > will have *one* and *only* one set of recognized instructions.  (The "hidden
618 > > prefix" is the immutable vendor/arch/impl tuple in my proposals.) 
619 >
620 >  ah this is an extremely important thing to clarify, the difference
621 > between the recognised instruction assembly mnemonic (which must be
622 > globally world-wide accepted as canonical) and the binary-level encodings
623 > of that mnemonic used different vendor implementations which will most
624 > definitely *not* be unique but require "registration" in the form of
625 > atomic acceptance as a patch by the FSF to gcc and binutils [and other
626 > compiler tools].
627
628
629 # References
630
631 * <https://groups.google.com/a/groups.riscv.org/forum/#!topic/isa-dev/7bbwSIW5aqM>
632 * <https://groups.google.com/a/groups.riscv.org/forum/#!topic/isa-dev/InzQ1wr_3Ak%5B1-25%5D>
633 * Review mvendorid-marchid WARL <https://groups.google.com/a/groups.riscv.org/forum/#!topic/isa-dev/Uvy9paXN1xA>