Having had some experience with shower drywall problems, let me start off by saying that, depending on where the damage is, it was probably caused either by someone having used grout instead of caulking at the joint between the tiling and the tub, or by inadequate/failed/no caulking around shower handles or tub spout.
That being said, it is easier to answer your question about how much of the drywall should be replaced (and I'm sure it's drywall--cement board doesn't get ruined like that!). I assume some of the tiles have already come loose, so what you need to do is continue removing the loose tiles (some of them will seem tight, but it's only the grout between them that's holding them in) until you get to where the drywall underneath is sound.
If your tiles were installed with the old type non-acrylic adhesive (usually a brown/tan color) you're in luck, since this can be removed and the tiles re-used (what I do is boil the tiles, then pull or scrape the adhesive off while it's still soft from the heat). A white-colored adhesive is probably acrylic, and I've never been able to get that off.
You will probably need to remove some tiles from sound drywall, too, in order to get straight lines for the drywall repair. Try to get your putty knife under a layer of the drywall paper to avoid damaging the tile--unless you have a ready supply of new or leftover tiles, then that won't matter so much!
Patching drywall is actually more difficult than installing new, but the advantages are less demolition work and less re-tiling afterwards. Ideally, the drywall patch should be attached to the wall studs at both ends. Where this is not practical, a brace can be fashioned from a small piece of board or plywood, and held in place with screws through the existing drywall. This will ensure your repaired wall will be able to support the tile over it.
When you finally get to the re-tiling phase, be sure the edge where the existing tiles will meet the new has all the old grout removed, and that the wall is as flat as possible--especially at the edge near the existing tile, where lumps of old adhesive may be lurking, and where new and old drywall meet (a trick here is to use nylon--not paper--drywall tape and mud it with the tile adhesive instead of drywall compound).
Finally, be sure to keep the new tile grout out of the joint at the edge of the tub, and fill that instead with the best tub caulking you can find!